Ahmed Alsahli Ahmed Alsahli - 1 year ago 72
AngularJS Question

Represent ng-model in a controller

I am developing application using AngularJS and ASP.Net MVC...

In my view, I have used

ng-repeat=u in users
in a
. Inside it, I set the
in a textbox as
is database field.

My question is, how I can represent the
in the angular controller??

For example, I tried to use
but it doesn't work.

Answer Source

Note that u is only existing in ng-repeat block. If you want to show/access to value changed by textbox outside of block, you should access via users again with another ng-repeat block:

<li ng-repeat="u in users">{{u.fName}}</li>

Or add ng-change="change(u)" to your textbox to get u anytime it's changed.

<input ng-model="u.fName" ng-change="change(u)" />

Plunkr example