Angular 2 ngfor first,last,index loop
发布时间:2020-12-17 08:03:42 所属栏目:安全 来源:网络整理
导读:我试图在此示例中将第一次出现设置为默认值: plunkr 收到以下错误: Unhandled Promise rejection: Template parse errors:TypeError: Cannot read property 'toUpperCase' of undefined ("dButtonToggleGroup" md-button-toggle [ERROR -]*ngFor="let indi
我试图在此示例中将第一次出现设置为默认值:
plunkr
收到以下错误: Unhandled Promise rejection: Template parse errors: TypeError: Cannot read property 'toUpperCase' of undefined ("dButtonToggleGroup"> <md-button-toggle [ERROR ->]*ngFor="let indicador of indicadores; #first = first" value="indicador.id" [checked]="first"> "): ng:///AppModule/HomeComponent.html@35:78 Parser Error: Unexpected token #,expected identifier,keyword,or string at column 31 in [let indicador of indicadores; #first = first] in ng:///AppModule/HomeComponent.html@35:78 (" <md-button-toggle *ngFor="let indicador of indicadores; #first = first" value="indicador.id" [ERROR ->][checked]="first"> <span>{{ indicado"): ng:///AppModule/HomeComponent.html@35:153 哪里不对??
看看这个
plunkr。
绑定到变量时,需要使用括号。此外,当您想要获取html中元素的引用时,可以使用hashtag,而不是在类似模板中声明变量。 <md-button-toggle *ngFor="let indicador of indicadores; let first = first;" [value]="indicador.id" [checked]="first"> ... 编辑: >指数>首先>最后>甚至>奇怪 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |