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('කන්ස්ට්රක්ටරය ආරම්භ විය');
}
ngOnInit() {
console.log('onInit යොදවා ඇත');
}
ngOnDestroy() {
console.log('onDestroy යොදවා ඇත');
}
}
Задание 1
ප්රතික්රියාශීලී
if කොන්දේසිය මත ක්රියාකාරී කොටස් දෙකේම ක්රියාකාරිත්වය පරීක්ෂා කරන්න.
Задание 2
ප්රතික්රියාශීලී ලූපය මත ක්රියාකාරී කොටස් දෙකේම ක්රියාකාරිත්වය පරීක්ෂා කරන්න.