I use to bind keyup on all input elements in jQuery like this:
$("input[type='text']").keyup(doSomething);
How can I do this from inside angular controller? I do not want to write ng-keyup on every input element.
I use to bind keyup on all input elements in jQuery like this:
$("input[type='text']").keyup(doSomething);
How can I do this from inside angular controller? I do not want to write ng-keyup on every input element.
Edit: This question was original with Angular 2 tag, So the Answer has Angular 2 reference. I'll delete this answer, since this is no longer valid.
Don't use jQuery in Angular 2 applications. Although you can use that but it is highly discouraged. There is an Angular way to bind the events. i.e. in view:
<button (keyup)="foo($event)">
in component:
foo(event) {
console.log(event.target);
}
Source: Angular Cheat Sheet