Следите за новинками
в нашем Telegram канале. Жми, чтобы подписаться:)
⊗jsagPmLCSH 73 of 97 menu
◀ ▶

Multiple Hooks in Angular

You can set multiple hooks at the same time. Let's see how this is done using the two hooks we've already studied.

We import two interfaces:

import { OnInit, OnDestroy } from '@angular/core';

Let's connect them to the class:

export class UserComponent implements OnInit, OnDestroy { }

Let's write our two hooks:

export class UserComponent implements OnInit, OnDestroy { constructor() { console.log('constructor is started'); } ngOnInit() { console.log('onInit is applied'); } ngOnDestroy() { console.log('onDestroy is applied'); } }

Test both hooks on the reactive condition if.

Test both hooks on the reactive loop.

← →
↑
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