我觉得我缺少一些东西,但是当我尝试在我的模板中使用数据属性,像这样:
<ol class="viewer-nav"><li *ngFor="#section of sections" data-sectionvalue="{{ section.value }}">{{ section.text }}</li></ol>
Angular2崩溃:
EXCEPTION: Template parse errors: Can’t bind to ‘sectionvalue’ since
it isn’t a known native property (“]data-sectionvalue=”{{ section.value }}”>{{ section.text }}
@H_502_11@我明显缺少一些与语法,请帮助。
请改用属性绑定语法
<ol class="viewer-nav"><li *ngFor="let section of sections" [attr.data-sectionvalue]="section.value">{{ section.text }}</li> </ol>
要么
<ol class="viewer-nav"><li *ngFor="let section of sections" attr.data-sectionvalue="{{section.value}}">{{ section.text }}</li> </ol>