2017-04-18 52 views
0

我有一個標準JSON,我使用ng-repeat在div上輸出。在ng-repeat中使用多個角度濾鏡

[ 
{ 
    "info": "CA", 
    "label": "STATE", 
    "displayLabel": "['pInformation']['State__c']", 
    "type": "string", 
    "group": "Custom Properties", 
    "collapse": true, 
    "editing": false 
}, 
{ 
    "info": "2017-04-17T23:29:37.000Z", 
    "label": "Date Time", 
    "displayLabel": "['pInformation']['DateTime__c']", 
    "type": "string", 
    "group": "Custom Properties", 
    "collapse": true, 
    "editing": false 
    }, 
{ 
    "info": "2017-23-17T23:32:37.000Z", 
    "label": "Date", 
    "displayLabel": "['pInformation']['Date__c']", 
    "type": "string", 
    "group": "Custom Properties", 
    "collapse": true, 
    "editing": false 
    } 
] 

<dl ng-repeat="fields in data.fields"> 
    <dd>{{fields.label}}</dd> 
    <dd>{{fields.info}}</dd> 
</dl> 

如果我想添加的角度日期濾波器用於第二和第三節點:

  • 第二:日期: 'MM-DD-YYYY HH:MM'
  • 第三:日期: 'MM-DD-YYYY'

回答

0

使用$指數:

<dl ng-repeat="fields in data.fields"> 
<div ng-show="$index != 1 || $index != 2"> 
    <dd>{{fields.label}}</dd> 
    <dd>{{fields.info}}</dd> 
</div> 
<div ng-show="$index == 1 || $index== 2"> 
    <dd>{{fields.label}}</dd> 
    <dd>{{fields.info || someDateFilter}}</dd> 
</div> 
</dl>