3

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/

3
  • Sorry, no idea what you are asking. Instead of pointing to your live link. Prepare a plunkr and explain the problem statement. 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}} Commented Oct 19, 2014 at 0:33
  • In the getFeeder if you do return $scope[idr] what happens? Commented Oct 19, 2014 at 0:34

1 Answer 1

8

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.