Angularjs: Onchange Event When The User Hits Enter
I have a HTML table in which one of the column is editable I have an ang
{{list.grade}}
Solution 1:
You can do it like this:
<tdng-model="row.grade"contenteditableng-keypress='keyPressed($event)'></td>
So, ng-model
and contenteditable
must be on the same element.
Also, if you specify ng-model
on a element, all of its content will be replaced by the value from a model. So it should be empty.
And
$scope.keyPressed = function (e){
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) { // 'Enter' keycode$scope.getInformation(); // your function here or some other code
e.preventDefault();
}
}
Here is working Plunkr: http://plnkr.co/edit/sHHlqF
Why do you use contenteditable
? Maybe you could use just <input ng-model...>
?
Post a Comment for "Angularjs: Onchange Event When The User Hits Enter"