【发布时间】:2016-09-14 20:58:36
【问题描述】:
我有以下选择(PUG)
select.custom-select(name='category', formControlName='category')
option(*ngFor="let category of essentials.categories") {{category.name}}
此代码有效,但我想将表单控件绑定到category.code,例如:
select.custom-select(name='category', formControlName='category')
option(*ngFor="let category of essentials.categories" [ngValue]="category.code") {{category.name}}
使用上面的代码,我收到一个错误 (Can't bind to 'ngFor' since it isn't a known property of 'option')。我也尝试过[value]="category.code",但没有成功...
编辑:我正在使用 Angular 2 RC7
【问题讨论】:
-
你试过这样
select.custom-select(name='category', formControlName='category', '*ngFor'="let category of essentials.categories", '[ngValue]'="category.code") {{category.name}}吗? ` -
@mic4ael 不,但它似乎不正确......循环必须在选项而不是选择中(根据所有文档)..我会试一试跨度>
-
它不起作用:(