jeudi 5 février 2015

Ng-model not updating after resetting textarea in AngularJS


I have been scratching my head over this problem for a while now. I have made a textarea and created a model with ng-model. This works all fine. I also have a button with plain Javascript and I am resetting the textarea to containing nothing. The binding stops working at that moment and I still can see my text in the other field, but the textarea is emtpy. I have recreated the problem here Fiddle.



window.onload = function () {
document.getElementById('btn').onclick = function () {
document.getElementById('textarea').value = "";
};
};


Am I missing something here or is this not how binding works in Angular. When I start retyping it starts 'listening' again and displays the correct text.


Does somebody have a clue or encountered this problem before?


Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire