⊗jsagPmLpEH 37 of 97 menu

Binding event handlers in an Angular template

In Angular, event handlers are attached to tags in a special way - using attributes. The event name is specified in parentheses, and the attribute value calls the component class method that should be executed by this event.

For example, let's make it so that when a button is clicked, the show method of the component class is executed:

<button (click)="show()"> button </button>

Now let's write the implementation of the show method in the component class:

export class AppComponent { public show(): void { alert('test'); } }

Make two buttons. When you click the first one, greet the user, and when you click the second one, say goodbye to him.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline