Skip to main content

Posts

Showing posts with the label angular 2 events example

Angular 2 KeyPress Event Textbox

Angular 2 KeyPress Event Textbox – Examples 1.       The KeyDown event is triggered when the user presses a Key. 2.       The KeyUp event is triggered when the user releases a Key. 3.       The KeyPress event is triggered when the user presses & releases a Key. Stayed Informed – Angular2 Input Events and Examples The examples for KeyPress event , Syntax:-  <input type= "text" [( value )]=" values " ( keypress )=" onKeyPress ($ event )" /> HTML Component – <div class= "ibox-title" > keypress Event - <input type= "text" [( value )]=" values " ( keypress )=" onKeyPress ($ event )" /> <span><strong class= "txt-color" > Resut- </strong> {{values}} </span> </div> Home Component – import { Component } from '@angular/core' ; import { CommonModule } from '@angular/common' ; @ Compon...

angular 2 events example

For example, the component class and HTML template as given below. import {Component} from 'angular2/core' ; @Component({     selector: 'myApp'     templateUrl: '<div><button (click)="myClicked()">ClickMe</button></div>' }) class MyComponent {         myClicked() {         }  } export class myApp_Component { } The HTML template as given below. <button (click) ="myClicked()">ClickMe</button> In the above, the myClicked() method will be called after clicked on button and we can also capture the event object using $event as parameter. i.e. <button (click)="myClicked($event)">ClickMe</button> and also in component class class MyComponent {         myClicked(event) {         }  } In the b...