当我的用户确实单击保存->
时,我想在Angular中禁用按钮HTML->
<form #myForm="ngForm" (ngSubmit)="save(myForm)">
<button class="btn btn-sm btn-success" [disabled]="myForm.form.pristine">Save</button>
.ts
save(myForm: NgForm) {
myForm.form.pristine;
}
然后,如果我的用户确实更改了表单,则需要激活我的按钮。
Error->
{
"message": "unused expression, expected an assignment or function call (no-
答案 0 :(得分:1)
[disabled]="myForm.form.pristine"
是什么意思? @Input() disabled: boolean //Whether the component is disabled.
<form #myForm="ngForm" (ngSubmit)="save(myForm)">
<button class="btn btn-sm btn-success" [disabled]="isDisbled">Save</button>