Hi Sadha,

Gordon is right. ng-include creates a new scope. However, this is not where 
you problem is coming from. As Gordon pointed out you have 3 
ng-controller=’pageController’.
This will get you 3 new controllers, all different from each other. If this 
is what you need, fine, but it will never give you what you need in this 
case.
I also fixed up your plunk to do what is expected. Its similar to that of 
Gordon, (I was away from my desk, and came back playing with your plunk, I 
just came back here and saw Gordon’s reply ;) )
this is what I have done, and why!


   1. Moved the ng-controller to the body tag. As you aptly named it 
   pageController, that seemed the right place. removed all the other 
   ng-controllers.
   2. Removed the $scope.inp from the script. As every ng-include gets it 
   own new scope, and it was only used as a temp var to be pushed into the 
   array.
   in a real application you might want to create a separate controller to 
   handle this stuff. for now I just declared it in the view.
   Also, you should look up the Angular dot rule!
   3. Changed the ng-click to take the inp as an argument. This is 
   important! ng-include creates its own new scope, and the function pushValue 
   is
   declared on a higher-up scope. The higher-up scope has no access to the 
   child’s scopes inp (dot rule again..)

Well, that’s about it I guess,
If you have further questions, don’t hesitate to ask!

Regards
Sander

-- 
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 http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to