<h3 style="color:#00bfff;margin:-14px 0 16px 0px" class="inline" *ng-if="data.for == 'next'">
{{data.bannerText}}<sup><small>{{data.super}}</small></sup>
</h3>
<span class="NotinStockGrey"> {{data.textOne}} </span>
<span style="color:#00bfff"> {{data.textTWo}} </span>
错误:
zone.js:420未处理的承诺拒绝:模板解析错误: 无法绑定到'ng-if',因为它不是'h3'的已知属性。 (“0Fb;保证金:-16px 0 16px 0px”&gt;
答案 0 :(得分:6)
它的
*ngIf="..."
(不是ng-if
)
https://angular.io/docs/ts/latest/api/common/index/NgIf-directive.html
您还需要将BrowserModule
(AppModule
)或CommonModule
添加到imports: []
的{{1}},以使其可用于模块的组件。< / p>
答案 1 :(得分:3)
您必须使用* ngIf而不是* ng-if。
f(x)
答案 2 :(得分:3)
The attribute ng-if is changed in Angular2+, so simply use *ngIf="whatever"
Something like below:
<div *ngIf="userObservable | async as user; else loading">
Hello {{user.last}}, {{user.first}}!
</div>
Or something like this:
<div *ngIf="mate">
Hello {{ mate }}!
</div>