gpt4 book ai didi

javascript - <垫单选按钮> : No value accessor

转载 作者:行者123 更新时间:2023-12-03 02:36:42 26 4
gpt4 key购买 nike

我有这个 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com