[Angular 2] Event in deep

时间:2023-03-09 04:54:51
[Angular 2] Event in deep

This lesson talks about the benefits of using the parens-based (click) syntax so that Angular 2 can handle any custom event. Then the video explains how to pass in the actually event object using the familiar $event syntax.

import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; @Component({
selector: 'app',
template: `
<div>
<input type="text" #myInput>
<button (mouseenter)="onClick($event, myInput.value)">Click Me</button>
</div>
`
}) class App{
onClick(event, value: string){
console.log(event, value);
}
} bootstrap(App);