Heim > Fragen und Antworten > Hauptteil
.directive('formComs',function(){
return {
restrict:'E',
template:'<p ng-if="{{item.name}} " class="item-input item-stacked-label" id="{{item.id}}" name="{{item.title}}">'+
'<span class="input-label">{{item.title}}</span>'+
'<input type="text">'+
'</p>' ,
replace:true,
}
})
html:<form-coms ng-repeat="item in items" ></form-coms>
大家讲道理2017-05-15 16:56:42
根据 https://docs.angularjs.org/api/ng/directive/ngIf,ng-if
的值是 expression
。所以改成ng-if="item.name"
就好了