亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

angular.js - The ng-repeat loop object is a string. How can I convert it into an array object through a filter on the page?
迷茫
迷茫 2017-05-15 17:08:44
0
1
666

$scope.data=[
{"type":"00",
"obj":"[{"name":"a1","age":21},{"name" :"a2","age":21},{"name":"a3","age":21 }]"},
{"type":"01",
"obj":"[{"name":"a1","age":21},{"name":"a2" ,"age":21},{"name":"a3","age":21}]"}
]

Page template
<ul ng-repeat="item in data">
<li ng-repeat="detail in item.obj">{{detail.name}}{{detail.age}}</li>
</ul>
But because item.obj is not a array but a string object. My current method is just to control Loop the data array in the controller and convert the obj object into json. However, this method is not efficient because it requires looping to modify the data in the controller.
So I would like to ask if there is any way to change the item on the page. obj is converted into an array object, making ng-repeat effective, similar to
<li ng-repeat="detail in {{item.obj|Filter method}}">{{detail.name}}</li>Principal or other feasible methods,

迷茫
迷茫

業(yè)精于勤,荒于嬉;行成于思,毀于隨。

reply all(1)
過去多啦不再A夢
angular.module('app', [])
  .filter('jsonParse', function() {
    return function (str) {
      try{
        return JSON.parse(str);
      }catch (e){
        return str;
      }
    }
  })
<ul ng-repeat="item in data">
  <li ng-repeat="detail in item.obj | jsonParse">{{detail.name}}{{detail.age}}</li>
</ul>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template