我希望在表单完成时禁用注册按钮。
<form [formGroup]="service.formModelInstrumexts" autocomplete="off" (submit)="onSubmit()"
style="background-color: #0067b8 !important; margin-top: 25px; margin-left: 600px; margin-right: 600px;">
<div style="padding: 15px">
<div>
<h3 style="color: azure">
اضافه کردن ساز
</h3>
</div>
<select id="ddl" style="width:200px; margin-right: 1%; margin-bottom: 10px; border-radius: 0px;" dir="rtl"
class="custom-select custom-select-sm">
<option> لطفا نوع ساز را انتخاب نمایید</option>
<option *ngFor="let item of type; let i = index" style="color: black;" (click)="test(item.id)" >{{item.name}}
</option>
</select>
<div class="form-group">
<label>نام</label>
<input style="width: 40%; margin-left: 60%; border-radius: 0px;" class="form-control" formControlName="Name">
</div>
<div class="form-group">
<label>توضیحات</label>
<textarea [(ngModel)]="name" style="direction: rtl; color: rgb(3, 0, 0); border-radius: 0px;" class="form-control" formControlName="Comment"
aria-label="With textarea"></textarea>
</div>
<div *ngIf="name != null" >
<app-upload style=" width: 100px; "
(onUploadFinished)="uploadFinished($event)"></app-upload>
<img src="http://localhost:54277/{{this.response.dbPath}}" *ngIf="this.response.dbPath != null" width="200px"
height="200px">
</div>
<div class="form-row">
<div class="form-group col-md-8 offset-md-2">
<button style="width: 100px; color: #0067b8; background-color: #fff; border-color: transparent; border-radius: 0px;margin-left: 8px;" type="submit" class="btn btn-lg btn-block"
[disabled]="!service.formModelInstrumexts.valid" >ثبت
</button>
</div>
</div>
</div>
</form>
您的提交按钮将取决于表单有效性。
[disabled]= "!service.formModelInstrumexts.valid"
另一种方法是模板引用变量
<form #myForm [formGroup]="service.formModelInstrumexts" (submit)="onSubmit()">
然后
[disabled]= "!myForm.valid"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句