[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);
原文地址:https://www.cnblogs.com/Answer1215/p/5297071.html