javascript - ng-enter with out calling any function -
the below code part of todo-list code.
the first line input box value accessible through newtodo.the input box used type new task in todo-list.
<input class="todofield" id="newtodofield" type="text" ng-model="newtodo" placeholder="add new todo" ng-enter> <button id="todosubmit" class="btn btn-default" ng-click="addtodo()">add</button>
there 2 way submit newly typed task name js.
1.after typing task name clicking add button(the button in second line) of code.which calling addtodo()
js function job of adding typed text in todo-list.
2.after typing task name pressing enter button in input box.
the doubt second type method.because ng-enter does't call function. written in end of tag.( if code
ng-enter="addtodo()"
means have understood)and more on if ng-enter does't call function second method works nicely.how
ng-enter
model supposed calladdtodo()
function.
the complete code available in this_link. demo of complete program available in this_link
sorry if question basic.
the doubt second type method.because ng-enter does't call function. written in end of tag.( if code ng-enter="addtodo()"
means have understood)
frankly speaking there no documentation ng-enter
@ angular docs can make work using directive ngenter
like:
app.directive('ngenter', function() { return function(scope, element, attrs) { element.bind("keydown", function(ev) { if(ev.which === 13) { scope.addtodo(); ev.preventdefault(); } }); }; });
Comments
Post a Comment