如何将if if放入ng-repeat语句中

时间:2017-01-03 16:35:50

标签: angular

     <div ng-repeat="d in data" ng-if="data.length>0">                                                    
         <div ng-bind="d.aa"></div>
         <div ng-bind="d.bb"></div>        
         <div ng-if="d.test == 'true'">
           <div ng-bind="it's test" />
           </div>    
         </div>
     </div>

内容:

  1. 我需要显示d.test = true表示,它的测试就像。
  2. 通常ng-if工作正常,使用ng-repeat和ng-bind它不起作用。
  3. 请帮助

1 个答案:

答案 0 :(得分:4)

var websocketExtensions = _.once(function () {
var extensions = [];

var websocketCompressionConfig = process.env.SERVER_WEBSOCKET_COMPRESSION
    ? JSON.parse(process.env.SERVER_WEBSOCKET_COMPRESSION) : {};
if (websocketCompressionConfig) {
extensions.push(Npm.require('permessage-deflate').configure(
  websocketCompressionConfig
));
}

return extensions;
});

你也可以使用

<div ng-repeat = "data in comments">
    <div ng-if="data.length >0">
        //different template with 0 data
    </div>
    <div ng-if="data.type == 'story' ">
        //different template with story data
    </div>
    <div ng-if="data.type == 'article' ">
        //different template with article data
    </div> 
</div>