javascript - ng-repeat dynamic array name -
is possible achieve dynamic array name, friends+$index
. example:
ng-repeat="friend in {{'friends'+$index}}"
the aim loop through different arrays: friends1 & friends2. tried everything, combination, without success. never came across appropriate answers.
thanks in advance.
you can this.
http://jsfiddle.net/jigardafda/gw7f1qq0/1/
html
<div ng-app="myapp"> <div ng-controller="myctrl"> <div ng-repeat="(name, value) in frndslist"> {{name}} <div ng-repeat="item in value.list"> {{item}} </div> </div> </div> </div>
js
var myapp = angular.module('myapp',[]); myapp .controller('myctrl', function ($scope, $rootscope) { $scope.frndslist = { 'friend1': { name: 'x1 frnd', list: [ "1.some1", "1.some2" ] }, 'friend2': { name: 'x2 frnd', list: [ "2.some1", "2.some2" ] } }; });
Comments
Post a Comment