2017-09-29 69 views
0

我從API獲取信息,其中一個返回的值是優惠券列表。每例如:來自API響應的Concat值

[{"Consecutive":11,"Code":"E5ZQHZ","Cvv":"GNH","IdCoupon":77236},{"Consecutive":12,"Code":"WM96FY","Cvv":"NGE","IdCoupon":77237}] 

我需要做的是從連續的代碼,CVV串聯的值,並將其像一個列表(像這樣):

<ul> 
<li>'Code'/'cvv'/'consecutive'</li> 
<li>'Code'/'cvv'/'consecutive'</li> 
</ul> 

我怎麼能這樣做?我正在使用JavaScript和AngularJs。

回答

0

您可以在ul使用ng-repeat像這樣:

var app = angular.module('myApp', []); 
 
app.controller('myCtrl', function($scope, $http) { 
 
    $scope.data = [{ 
 
    "Consecutive": 11, 
 
    "Code": "E5ZQHZ", 
 
    "Cvv": "GNH", 
 
    "IdCoupon": 77236 
 
    }, { 
 
    "Consecutive": 12, 
 
    "Code": "WM96FY", 
 
    "Cvv": "NGE", 
 
    "IdCoupon": 77237 
 
    }]; 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<div ng-app="myApp" ng-controller="myCtrl"> 
 
    <ul ng-repeat="d in data"> 
 
    <li>{{d.Code}}/{{d.Cvv}}/{{d.Consecutive}}</li> 
 
    </ul> 
 
</div>

還有其他可能的解決方案,但是這應該爲您建立很好。