首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ng-重复从angularJS中的Json数组中获取特定值

使用ng-重复从angularJS中的Json数组中获取特定值
EN

Stack Overflow用户
提问于 2016-03-07 10:16:36
回答 2查看 133关注 0票数 0

部分代码

代码语言:javascript
复制
.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;
    });
  }
])
代码语言:javascript
复制
<ul ng-repeat="item in datab">
  <li ng-repeat="value in item.date track by $index">{{value}}</li>
</ul>

JSON

代码语言:javascript
复制
{
  "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的新手,只想显示datetype,但还没有进展。

任何帮助都将不胜感激!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-07 10:26:40

你可以试试这样的东西:

代码语言:javascript
复制
<ul ng-repeat="item in datab">
  <li ng-repeat="value in item">
    {{value.date}}
  </li>
</ul>

JSFiddle

票数 1
EN

Stack Overflow用户

发布于 2016-03-07 10:32:36

试试这个:

代码语言:javascript
复制
.controller('HomeCtrl', ['$scope','$stateParams','lastactivities',
 function($scope, $stateParams,lastactivities) {
  var mytoken = sessionStorage.getItem('token');
  lastactivities.send(mytoken).then(function(activities){

  var activitytab = activities.data;

   var data=[];
for (var i=0;activities.data.length>0,i++)
{
    for(var j=0;activities.data[i].activities.length>0;j++)
    {
        data.push({date: activities.data[i].date, Type: activities.data[i].activities[j].type})
    }
}

  $scope.datab = data;

  });
 }
])
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35841057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档