.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>
Menurut https://docs.angularjs.org/api/ng/directive/ngIf, nilai
ng-if
ialahexpression
. Jadi cuma tukar kepadang-if="item.name"