Angular-এ একাধিক হুক

একই সাথে একাধিক হুক সেট করা সম্ভব। আসুন দেখি কিভাবে এটি করা যায় ইতিমধ্যে শেখা দুটি হুকের উদাহরণে।

দুটি ইন্টারফেস ইম্পোর্ট করি:

app/user/user.component.tsimport { OnInit, OnDestroy } from '@angular/core';

সেগুলো ক্লাসের সাথে সংযুক্ত করি:

app/user/user.component.tsexport class UserComponent implements OnInit, OnDestroy {
  
}

আমাদের দুটি হুক লিখি:

app/user/user.component.tsexport class UserComponent implements OnInit, OnDestroy {
  constructor() {
    console.log('constructor is started');
  }
  
  ngOnInit() {
    console.log('onInit is applied');
  }
  
  ngOnDestroy() {
    console.log('onDestroy is applied');
  }
}
Задание 1

রিঅ্যাকটিভ if শর্তে উভয় হুকের কাজ পরীক্ষা করুন।

Задание 2

রিঅ্যাকটিভ লুপে উভয় হুকের কাজ পরীক্ষা করুন।