【发布时间】:2016-03-07 10:16:36
【问题描述】:
部分代码
.controller('HomeCtrl', ['$scope', '$stateParams', 'lastactivities',
function($scope, $stateParams, lastactivities) {
var mytoken = sessionStorage.getItem('token');
lastactivities.send(mytoken).then(function(activities) {
var activitytab = activities.data;
$scope.datab = activities.data;
});
}
])
<ul ng-repeat="item in datab">
<li ng-repeat="value in item.date track by $index">{{value}}</li>
</ul>
JSON
{
"erreur": "",
"data": [{
"date": "2016-03-04",
"activities": [{
"type": "bank",
"icon": {
"type": "lock-3",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": null,
"title": "MOT DE PASSE MODIFIÉ",
"description": ""
}, {
"type": "client",
"icon": {
"type": "document-1",
"color": "#000000"
},
"badge": {
"text": "1 400 €",
"color": "#ffffff",
"backgroundColor": "#97d42e"
},
"action": "925",
"title": "FACTURE",
"description": "nike - appli mobile"
}, {
"type": "client",
"icon": {
"type": "user-1",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": 925,
"title": "NOUVEAU CLIENT",
"description": "nike"
}]
}, {
"date": "2016-03-03",
"activities": [{
"type": "bank",
"icon": {
"type": "lock-3",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": null,
"title": "MOT DE PASSE MODIFIÉ",
"description": ""
}, {
"type": "client",
"icon": {
"type": "document-1",
"color": "#000000"
},
"badge": {
"text": "643,44 €",
"color": "#ffffff",
"backgroundColor": "#f84c74"
},
"action": "719",
"title": "FACTURE EN RETARD",
"description": "Justine - Facture 2"
}, {
"type": "client",
"icon": {
"type": "document-1",
"color": "#000000"
},
"badge": {
"text": "400 €",
"color": "#ffffff",
"backgroundColor": "#f84c74"
},
"action": "719",
"title": "FACTURE EN RETARD",
"description": "Justine - Ma first facture"
}]
}, {
"date": "2016-02-18",
"activities": [{
"type": "bank",
"icon": {
"type": "lock-3",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": null,
"title": "MOT DE PASSE MODIFIÉ",
"description": ""
}]
}, {
"date": "2016-02-08",
"activities": [{
"type": "bank",
"icon": {
"type": "lock-3",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": null,
"title": "MOT DE PASSE MODIFIÉ",
"description": ""
}]
}, {
"date": "2016-02-02",
"activities": [{
"type": "client",
"icon": {
"type": "document-1",
"color": "#000000"
},
"badge": {
"text": "0 €",
"color": "#ffffff",
"backgroundColor": "#97d42e"
},
"action": "724",
"title": "FACTURE",
"description": "Test client - F - 00005"
}, {
"type": "client",
"icon": {
"type": "document-1",
"color": "#000000"
},
"badge": {
"text": "0 €",
"color": "#ffffff",
"backgroundColor": "#97d42e"
},
"action": "720",
"title": "FACTURE",
"description": "Abus - F - 00004"
}]
}, {
"date": "2016-02-01",
"activities": [{
"type": "client",
"icon": {
"type": "user-1",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": 724,
"title": "NOUVEAU CLIENT",
"description": "Test client - Scooby"
}, {
"type": "client",
"icon": {
"type": "document-1",
"color": "#000000"
},
"badge": {
"text": "1 500 €",
"color": "#ffffff",
"backgroundColor": "#97d42e"
},
"action": "720",
"title": "FACTURE",
"description": "Abus - Fact"
}, {
"type": "client",
"icon": {
"type": "user-1",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": 720,
"title": "NOUVEAU CLIENT",
"description": "Abus - Busbus"
}, {
"type": "document",
"icon": {
"type": "download-6",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": null,
"title": "7 DOCUMENTS DÉPOSÉS",
"description": "retrait-par-carte-Invalid date.jpg, Document-01-02-2016.jpg, Doss1, Doss2, Document-01-02-2016.jpg, -Invalid date.jpg, retrait-par-carte-01-02-2016.jpg"
}, {
"type": "client",
"icon": {
"type": "document-1",
"color": "#000000"
},
"badge": {
"text": "643,44 €",
"color": "#ffffff",
"backgroundColor": "#97d42e"
},
"action": "719",
"title": "FACTURE",
"description": "Justine - Facture 2"
}, {
"type": "bank",
"icon": {
"type": "lock-3",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": null,
"title": "MOT DE PASSE MODIFIÉ",
"description": ""
}, {
"type": "client",
"icon": {
"type": "document-1",
"color": "#000000"
},
"badge": {
"text": "400 €",
"color": "#ffffff",
"backgroundColor": "#97d42e"
},
"action": "719",
"title": "FACTURE",
"description": "Justine - Ma first facture"
}, {
"type": "client",
"icon": {
"type": "user-1",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": 719,
"title": "NOUVEAU CLIENT",
"description": "Justine - Arma"
}, {
"type": "bank",
"icon": {
"type": "flag-1",
"color": "#000000"
},
"badge": {
"text": "",
"color": "#000000",
"backgroundColor": "transparent"
},
"action": null,
"title": "BIENVENUE À BORD DE TIIME AE",
"description": "C'est parti pour 30 jours offerts"
}]
}]
}
我是AngularJS 的新手,我试图只显示date 和type,但还没有运气。
任何帮助将不胜感激!
【问题讨论】:
-
尝试
<ul ng-repeat="item in datab">然后<li>{{item.date}}</li> -
它运作良好非常感谢你:)
-
@user3130401,请将此作为答案发布,以便我们将其选为正确答案。
标签: arrays angularjs json angularjs-ng-repeat