search

Home  >  Q&A  >  body text

angular.js - Using ng-if="{{item.name}}" in the directive template of angularjs reports an error

.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>
淡淡烟草味淡淡烟草味2866 days ago574

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-05-15 16:56:42

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

    reply
    0
  • Cancelreply