MEAN Web Development - Second Edition by Amos Q. Haviv

MEAN Web Development - Second Edition by Amos Q. Haviv

Author:Amos Q. Haviv [Haviv, Amos Q.]
Language: eng
Format: mobi
Publisher: Packt Publishing
Published: 2016-11-29T16:00:00+00:00


Event binding

In order for your component to respond to the DOM event generated from the view, Angular 2 provides you with the mechanism of event binding. To bind a DOM event to a component method, all you have to do is set the event name inside round brackets, as shown in the following example:

import { Component } from '@angular/core'; @Component({ selector: 'mean-app', template: '<button (click)="showMessage()" >Show Message</button>' }) export class AppComponent { showMessage() { alert('This is a message!') } }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.