.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>
根据 https://docs.angularjs.org/api/ng/directive/ngIf,
ng-if
的值是expression
。所以改成ng-if="item.name"
就好了