HI mathew,

try the below code.

<div data-ng-repeat="cust in customer" >
        <div ng-repeat="num in numbers"> {{changeCustomer(cust,num)  }} -
{{ cust.city }}
        </div>
</div>



//script..
$scope.changeCustomer = function(){


}



*Thanks & Regards*

*Kamalnath Gali,*
*Phno:+919160010428.*

On Tue, Apr 19, 2016 at 6:38 PM, <[email protected]> wrote:

> <!DOCTYPE html>
> <html data-ng-app ="myApp">
>     <head>
>         <title></title>
>         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>     </head><body  data-ng-controller="myCtrl">
>         <div >
>             <div data-ng-repeat="cust in customer" >
>                 <div ng-repeat="num in numbers"> {{ cust.name }} - {{
> cust.city }}
>                     <div  data-ng-if="num == 4"
>  data-ng-init="changeCustomer(cust)"></div>
>                 </div>
>
>              </div>
>         </div>
> <script src="
> http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js
> "></script>
> <script>
> var app = angular.module("myApp", []);
> app.controller("myCtrl", function($scope) {
>     $scope.customer = [{name: 'Jill', city : 'DL'},{name: 'Jack', city :
> 'KL'}];
>     $scope.numbers = [1,2,3,4,5];
>
>     $scope.changeCustomer = function(customer) {
>             customer.name = 'Mary';
>     }
>
> });
> </script>
> </body>
> </html>
>
> I have two ng-repeats for customer and number arrays. I am passing the
> first array object to the second ng-repeat and trying to change the first
> array object element in a particular condition. i.e, the name should change
> to 'Mary' only in the 4th iteration of the second array.
> Excepted output : Jill - DL
> Jill - DL
> Jill - DL
> Mary - DL
> Jill - DL.
> But when I run the code all the 'Jill' is replacing with 'Mary'.
> (output : Mary - DL
> Mary - DL
> Mary - DL
> Mary - DL
> Mary - DL.)
> Could you please help me to find a solution to change name only in the 4th
> iteration?
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to