我觉得我错过了什么.当我尝试data attribute在我的中使用时template,像这样:
<ol class="viewer-nav">
<li *ngFor="#section of sections" data-value="{{ section.value }}">
{{ section.text }}
</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
Angular 2 崩溃:
EXCEPTION:模板解析错误:无法绑定到"sectionvalue",因为它不是已知的本机属性("
] data-sectionvalue ="{{section.value}}"> {{section.text}}
我显然遗漏了一些语法,请帮忙.
<div data-value="{{tagName}}">{{tagName}}</div>
Run Code Online (Sandbox Code Playgroud)
获取div错误的"数据值不是有效属性".
我正在开发的Angular 2应用程序用于呼叫中心.
我创建了一个Angular 2组件,它是一个bootstrap模式.当我在页面上实例化一个或多个时,它可以很好地工作,并创建触发器来打开它们.那里没有问题.我已经彻底测试了那部分.
现在在我的应用程序中,我们有一个复选框列表,当点击时,会弹出一个模态,并指示呼叫中心代理在选择呼叫原因时进行覆盖.
要创建这些模态和触发器,这是我放置的代码:
<div class="checkbox" *ngFor="#case of caseTypes; #i = index" data-toggle="modal" data-target="modal-i">
<label>
<input type="checkbox" [(ngModel)]="case.selected"> {{case.title}}
</label>
<instructions-modal [instruction]="case.instructions" title="{{case.title}}" closeButtonTitle="Finished" modalId="modal-{{i}}"></instructions-modal>
</div>
Run Code Online (Sandbox Code Playgroud)
这似乎应该可以工作,但是当我转到页面时,我在浏览器控制台中收到以下错误:
EXCEPTION: Error: Uncaught (in promise): Template parse errors:
Can't bind to 'data-toggle' since it isn't a known native property ("ss="col-md-6">
<h4>Case Type</h4>
<div class="checkbox" *ngFor="#case of caseTypes; #i = index" [ERROR ->][data-toggle]="modal" [data-target]="modal-i">
<label>
<input type="checkbox" [(ngModel)]="cas"): CaseCreation@8:64
Can't bind to 'data-target' since it isn't a known native property ("ase Type</h4> …Run Code Online (Sandbox Code Playgroud) 我需要添加自定义数据属性来选择选项。我想要它,因为在更改时我想根据所选属性(而不是值)触发操作
这是我正在使用的代码
<select (domChange)="onListUpdate($event)" formControlName="region" id="region" class="selectric form-control">
<option code="" value="-1">{{ 'select_country' | translate }}</option>
<option data-isocode="{{region.iso_code}}" value="{{region.id}}" *ngFor="let region of regions">{{region.name['en']}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
例如,当我为数据属性赋予静态值时,它可以工作,以下工作没有任何问题(注意数据 isocode 具有静态值)
<option data-isocode="abc" value="{{region.id}}" *ngFor="let region of regions">{{region.name['en']}}</option>
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试在 data-isocode 中使用变量时
<option data-isocode="{{region.iso_code}}" value="{{region.id}}" *ngFor="let region of regions">{{region.name['en']}}</option>
Run Code Online (Sandbox Code Playgroud)
它引发了我以下错误
Can't bind to 'isocode' since it isn't a known property of 'option'
Run Code Online (Sandbox Code Playgroud)
如何使用 Angular 传递数据属性(如 jQuery)并使用 FormBuilder 获取值?
我有我的两个对象
{
"twitter": {
"username": "potus",
"postslimit": 10
},
"enum": [],
"publicationdate": "2018-08-27T15:05:55.410Z",
"_id": "5b8414ec3412b43a34f050cf",
"clicks": [],
"active": true,
"user": " __ ",
"type": "twitter",
"__v": 0
}
Run Code Online (Sandbox Code Playgroud)
如果我显示:
<a
class="twitter-timeline"
data-tweet-limit="2"
href="https://twitter.com/{{tw.twitter.username}}">
</a>
Run Code Online (Sandbox Code Playgroud)
一切正常,但是当我尝试data-tweet-limit像这样绑定时:
<a
class="twitter-timeline"
data-tweet-limit="{{tw.twitter.postslimit}}"
href="https://twitter.com/{{tw.twitter.username}}">
</a>
Run Code Online (Sandbox Code Playgroud)
我得到:
无法绑定到 'tweet-limit',因为它不是 'a' 的已知属性。("'"> ]data-tweet-limit="{{tw.twitter.postslimit}}" href="https://twitter.com/{{tw.twitter.username}}">