1

I am calling ng-int() on ng-repeat like this:

<ul class="title_page1" style="margin:0; padding:0;">
  <li  ng-init='some(val.id);'  ng-repeat="(key,val) in menu">{{val.name}}</span><span>{{size}}</span></li>
</ul>

I have three elements in menu, by this ng-init is getting called for each ng-repeat but {{size}} from some(val.id). I am getting same size for all the 3 elements. Please kelp me in sorting out this.

$scope.some={function(id){

     return $http({
         url : 'url+id',
         method : 'GET',
         async : false,
     }).success(function(data) { 
        $scope.size = data.length;
    });    
};
$scope.menu=[{java,php,micro}];

And this the thins I am doing but the size i am getting for all the elements is same. but i have seen in the google but i did not get any result from google

1 Answer 1

3

You are retrieving the data for 3 id's, however your saving them in the scope where your controller resides, which can only have one size variable. What I would do is save the size variable into the val object.

<ul class="title_page1" style="margin:0; padding:0;">
  <li  ng-init='some(val);'  ng-repeat="(key,val) in menu">{{val.name}}</span><span>{{val.size}}</span></li>
</ul>

$scope.some={function(val){

     return $http({
         url : 'url'+val.id,
         method : 'GET',
         async : false,
     }).success(function(data) { 
        val.size = data.length;
    });    
};
$scope.menu=[{java,php,micro}];
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.