角度显示重复键

时间:2016-12-12 06:01:29

标签: json angularjs-ng-repeat

我需要使用ng-repeat在产品AL200W401(不含xxxx)中显示密钥。在我的HTML代码中显示AL200W401xxxx。如何解决这个问题。

JSON

{  
    "kits":"B11D0W201,AL200W401",
     "dateTo":"13/12/2016",
     "orders":[  
         {  
             "AL200W401":1,
             "B11D0W201":0,
             "date":"13 Dec 16"
         }
     ],
    "dateFrom":"12/12/2016",
    "products":[  
    {  
        "AL200W401":"AL200W401xxxx",
        "B11D0W201":"B11D0W201xxxx"
    }
    ]
}

HTML

<th ng-repeat="column in products">{{column}}</th> 

3 个答案:

答案 0 :(得分:2)

还有其他类似的问题,其中解决方案的位置。例如,请检查this

所以你可以这样做:

body { 
    background-color:#ffe0e0!important; 
    color: #f54a63; 
    font-family: sans-serif; 
    font-size: 14px; 
    text-align: left; 
    line-height: 2; 
    position: relative; 
    top: -40px; 
    width: 100%; 
} 

body.home { 
    background: url(payload498.cargocollective.com/1/22/724019/12271389/gif1‌​4.gif) no-repeat center center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
} 

body.pages { 
    background-color: #ffe0e0!important;
}

请查看此工作演示:https://jsfiddle.net/hd84335/j0dr7bbp/

答案 1 :(得分:1)

txtName

答案 2 :(得分:1)

工作演示:

var myApp = angular.module('myApp',[]);

myApp.controller('MyCtrl',function ($scope) {
    $scope.jsonObj = {  
    "kits":"B11D0W201,AL200W401",
     "dateTo":"13/12/2016",
     "orders":[  
         {  
             "AL200W401":1,
             "B11D0W201":0,
             "date":"13 Dec 16"
         }
     ],
    "dateFrom":"12/12/2016",
    "products":[  
    {  
        "AL200W401":"AL200W401xxxx",
        "B11D0W201":"B11D0W201xxxx"
    }
    ]
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
 <div ng-repeat="(key,value) in jsonObj.products[0]">{{key}}</div>
</div>