角2数据属性 [英] Angular 2 data attributes
本文介绍了角2数据属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我觉得我失去了一些东西,但是当我尝试使用数据
属性在我的模板,像这样的:
I feel like I am missing something, but when I try to use a data
attribute in my template, like this:
<ol class="viewer-nav"><li *ngFor="#section of sections"
data-sectionvalue="{{ section.value }}">{{ section.text }}</li></ol>
Angular2与崩溃:
Angular2 crashes with:
例外:模板解析错误:无法绑定到'sectionvalue自
它不是一个已知的天然属性(
EXCEPTION: Template parse errors: Can't bind to 'sectionvalue' since it isn't a known native property ("
我缺少明显的语法的东西,请大家帮帮忙。
I'm obviously missing something with the syntax, please help.
推荐答案
使用属性绑定语法而不是
Use attribute binding syntax instead
<ol class="viewer-nav"><li *ngFor="#section of sections"
[attr.data-sectionvalue]="section.value">{{ section.text }}</li>
</ol>
或
<ol class="viewer-nav"><li *ngFor="#section of sections"
attr.data-sectionvalue="{{section.value}}">{{ section.text }}</li>
</ol>
这篇关于角2数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文