angular 4 中 *ngFor 和*ngIf 一起使用

原创 Been101 随笔 ng4 153阅读 2018-01-20 19:22:50 举报

在同一个标签中 同时使用 ngFor 和 ngIf 会报错 Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with
是因为 The
in *ngFor makes Angular to add a <template> tag. On a <template> tag this doesn't make sense and therefore here structural directives have a different syntax.

<li v-for = "item in lists" v-if="item.type == 1">{{item.type}}</li>
angular 4 中就要这么用了

<ng-container ngFor = "let item of lists">
ngIf = "item.type == 1">{{itemtype}}</li>

评论 ( 0 )

赶紧努力消灭 0 回复