angular.js - angularjs 的指令template中使用ng-if="{{item.name}}" 报错
淡淡烟草味
淡淡烟草味 2017-05-15 16:54:42
0
1
541
.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>
淡淡烟草味
淡淡烟草味

reply all(1)
大家讲道理

According to https://docs.angularjs.org/api/ng/directive/ngIf, ng-if 的值是 expression。所以改成ng-if="item.name" That’s it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template