我想禁用DOB字段以防止编辑,并且我想第二次禁用性别单选按钮,如果用户一次选择了性别并提交了该性别,那么下一次,如果他想要编辑配置文件并想要更改性别,那么它应该被禁用。我该怎么做到。
我已经累了,但是没工作
<div class="form-group label-floating">
<label class="control-label " for="name">Date of Birth</label>
<input type="text" class="form-control" formControlName='dob' id='dob' value="{{ dob | date:'dd-MMM-yyyy' }}" [readonly]="true">
<!-- <app-field-error-display [displayError]="this.validationService.isFieldValid(updateProfileForm,'dob')">
</app-field-error-display> -->
<span class='error-msg'></span>
</div>
<div class="form-group label-floating">
<label class="control-label " for="name">Date of Birth</label>
<input type="text" class="form-control" formControlName='dob' id='dob' value="{{ dob | date:'dd-MMM-yyyy' }}" [disable]="true">
<!-- <app-field-error-display [displayError]="this.validationService.isFieldValid(updateProfileForm,'dob')">
</app-field-error-display> -->
<span class='error-msg'></span>
</div>
`
<label class="radio-inline">
<span class="control-label gender_row">Gender </span>
<input [disabled]="true" type="radio" name="gender" value="1" formControlName='gender' [checked]="gender==1">Male
</label>
<label class="radio-inline">
<input type="radio" name="gender" value="2" formControlName='gender' [checked]="gender==2">Female
</label>
<!-- <label class="radio-inline">
<input type="radio" name="gender" value="3" formControlName='gender' [checked]="gender===3">Other
</label> -->
<label class="radio-inline">
<input type="radio" name="gender" value="3" formControlName='gender' [checked]="gender==3">Don't want to disclose
</label>
</div>`
这是我的看法 enter image description here
对于DOB字段,我想永久禁用,但对于性别字段,我想第二次禁用。一旦用户提交个人资料。
答案 0 :(得分:0)
如果为单选按钮填充了值,则可以将[disabled]属性设置为true,并以相同的方式将[readonly]属性设置为true。
<input type="date" [readonly]="!!birthdate" formControlName="birthdate">