我有这个 HTML:
<mat-radio-group>
<mat-radio-button [(ngModel)]="searchType">
And (Narrower search)
</mat-radio-button>
<mat-radio-button [(ngModel)]="searchType">
Or (Wider search)
</mat-radio-button>
</mat-radio-group>
我收到此错误:
Error: No value accessor for form control with unspecified name attribute
我尝试使用这个:
<mat-radio-button name="search-and"[(ngModel)]="searchType">
And (Narrower search)
</mat-radio-button>
我收到此错误:
Error: No value accessor for form control with name: 'search-and'
然后我尝试了这个:
<mat-radio-button value="search-and" name="search-and" [(ngModel)]="searchType">
And (Narrower search)
</mat-radio-button>
还有这个:
<mat-radio-button [value]="search-and" name="search-and" [(ngModel)]="searchType">
And (Narrower search)
</mat-radio-button>
我仍然收到此错误:
Error: No value accessor for form control with name: 'search-and'
最佳答案
尝试设置formControlName="SearchType"
上<mat-radio-group>
而不是<mat-radio-button>
.
关于javascript - <垫单选按钮> : No value accessor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48515312/