我想使用 *ngFor 将以下 HTML 代码转换为 Angular 代码
<div>Children: <input type="radio" id="1" name="children" [value]="1" [(ngModel)]="this.children"/>1
<input type="radio" id="2" name="children" [value]="2" [(ngModel)]="this.children"/>2
<input type="radio" id="3" name="children" [value]="3" [(ngModel)]="this.children"/>3
You have {{this.children}} children
</div>
角码
<div>Children: <input *ngFor = "let option of selectOptions" type="radio" id=option name="children" [value]=option [(ngModel)]="this.children"/>{{option}}
You have {{this.children}} children
</div>
selectOptions 在 Component 的类中定义如下:
selectOptions:Array<number>=[1,2,3]
我可以看到错误{{option}}
的是Angular: Identifier 'option' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
我也看到错误的id=option name="children"
那个tag start is not closed
。
我究竟做错了什么?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句