国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

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
656

$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)
過(guò)去多啦不再A夢(mèng)
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