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 : /
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/
Share Improve this question edited Oct 19, 2014 at 3:56 PSL 124k21 gold badges256 silver badges243 bronze badges asked Oct 18, 2014 at 22:58 zelocalhostzelocalhost 1,1833 gold badges21 silver badges40 bronze badges 3- Sorry, no idea what you are asking. Instead of pointing to your live link. Prepare a plunkr and explain the problem statement. – PSL Commented Oct 19, 2014 at 0:29
- I want to make 'feeder846097918756247' automatically constructed. The last li is what i want to get, i put it manually for show what i expected. '846097918756247' is in this case {{raterie.idFB}} – zelocalhost Commented Oct 19, 2014 at 0:33
-
In the getFeeder if you do
return $scope[idr]
what happens? – PSL Commented Oct 19, 2014 at 0:34
1 Answer
Reset to default 8Inorder 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>