问题
JSON array I am getting after get API call, I am getting following json response.
{
"reactions":[{
"severity":{
"label":"Severe"
},
"label":"Skin Rash"
}],
"audit":{
"source":"medicare",
"createDate":"2015-03-02T18:39:23Z",
"updateDate":"2015-03-02T18:39:23Z",
"version":"1"
},
"label":"Other - IODINE",
"ended":"2007-10-28T00:00:00-04:00",
"started":"1993-01-01T00:00:00-05:00",
"date":"2015-03-02T18:37:42Z"
}".
And I need to just display only
":[{"severity":{"label":"Severe"},"label":"Skin Rash"}]"
in li tag.
How can I do that ?
I need to populate this json array in <li>
in html5. How can I do it? I am using restangular.:
Angular JS file:
Restangular.one('APIName', Parameter_to_api).get().then(function (result) {
$scope.datalist= result;
}
HTML file
<ul class="links">
<li ng-repeat="data in datalist"></li>
</ul>
回答1:
Try this
var app = angular.module('app', []);
app.controller('firstCtrl', function($scope) {
$scope.datalist = {
data1: [2, 3, 4],
data2: [6, 7, 8, ],
data4: [9, 10, 12]
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="app">
<div ng-controller="firstCtrl">
<ul class="links" ng-repeat="data in datalist">
<li ng-repeat="i in data">{{i}}</li>
</ul>
</div>
</body>
来源:https://stackoverflow.com/questions/29111199/json-array-disply-in-li-using-angular-js