I am looking to update Phone Name in a list of phones using contenteditable attribute. I have tried using ng-change but thats not getting fired. Is there any way I can do this?
I have a list of Store.Phones
<ul class="store">
<li ng-repeat="Phone in Store.Phones">
<strong contenteditable> {{Phone.Name}}</strong>
</li>
<ul>
So now when I edit Phone name I need to get it updated in the list.
I have tried something like this with model pointing to the element. This is not working.
<strong ng-model='Store.Phones[$index].Name'> {{Phone.Name}}</strong>
Also
<strong ng-model='PhoneName' ng-change='PhoneNameChanged()'> {{Phone.Name}}</strong>
but in this case the method is not getting fired.
just remove
ctrl.$setViewValue(elm.html());
link to http://jsfiddle.net/blingz/B5UbE/12/
Edit
Here's an example based on the example in the Angular docs which just uses
ng-repeat
. Sinceng-repeat
creates a new scope for each iteration, it shouldn't be a problem.Original
There's an example of how you can do just that here: http://docs.angularjs.org/guide/forms
It's under the "Implementing custom form controls (using ngModel)" header.