Most of the DOM events are triggered by user input and bind to these events provides a way to get inputs from a user. The following example shows a click event binding – [on-click.component.ts] import { Component , OnInit } from '@angular/core' ; @ Component ({ selector: 'app-on-click' , templateUrl: './on-click.component.html' , styleUrls: [ './on-click.component.css' ] }) export class OnClickComponent implements OnInit { welcomeMsg = '' ; constructor () { } ngOnInit () { } onClick () { this . welcomeMsg = 'Welcome you, Anil!' ; } } And on-click.component.html - < div class = "msg" > < button ( click )= "onClick()" >C lick Me! </ button > ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers