Reputation: 1183
Into a first loop, which i recover an id, i try to define other loop like this :
<ul ng-show="feed{{raterie.idFB}} === true" ng-init="var myFeed = myFeedFunction(raterie.idFB);">
<li ng-repeat="feed in getFeeder(raterie.idFB) | limitTo:1">adoptions are : {{feed.title | cleanit}}</li>
<li ng-repeat="feed in feeder{{raterie.idFB}} | limitTo:1">adoptions are : {{feed.title | cleanit}}</li>
<li ng-repeat="feed in feeder{raterie.idFB} | limitTo:1">adoptions are : {{feed.title | cleanit}}</li>
<li ng-repeat="feed in feeder[raterie.idFB] | limitTo:1">adoptions are : {{feed.title | cleanit}}</li>
<li ng-repeat="feed in feeder['raterie.idFB'] | limitTo:1">adoptions are : {{feed.title | cleanit}}</li>
<li ng-repeat="feed in myFeed | limitTo:1">adoptions are : {{feed.title | cleanit}}</li>
<li ng-repeat="feed in feeder846097918756247 | limitTo:1">adoptions is : {{feed.title | cleanit}}</li>
<ul>
I don't understand how to make 'feeder846097918756247' automatically constructed. The last li is what i want to get, i put it manually with only one example into first loop
I try two solutions into $scope :
// define the value for ng-repeat (1st solution)
$scope.getFeeder = function(id) {
var idr = 'feeder' + id;
return idr;
}
// define the value for ng-repeat (2nd solution)
function myFeedFunction(pId) {
return eval('feeder' + pId) ;
}
It's doesn't work.
My online app is here : http://www.monde-du-rat.fr/pmr/
Upvotes: 3
Views: 9602
Reputation: 123739
Inorder to get
<li ng-repeat="feed in getFeeder(raterie.idFB) | limitTo:1">adoptions are : {{feed.title | cleanit}</li>
to work, you need to return the array from the scope property in getFeeder function.
$scope.getFeeder = function(id) {
return $scope['feeder' + id];
}
Or better, instead of putting feeder846097918756247
directly on the scope as a property. Place the respective data in an object on scope.
i.e
$scope.feeder = {};
$scope.feeder['846097918756247'] = someArray;
//etc...
and just do:-
<li ng-repeat="feed in feeder[raterie.idFB] | limitTo:1">adoptions are : {{feed.title | cleanit}}</li>
Upvotes: 8