ඔබගේ Angular යෙදුම් වලට නව මානයක් එක් කරන ගතික components, animations, server-side rendering, සහ ආරක්ෂාව වැනි උසස් සංකල්ප පිළිබඳව ඉගෙන ගනිමු.
සාමාන්යයෙන්, component එකක් template එක තුළ selector (`
උදාහරණයක් ලෙස, පරිශීලකයාගේ ක්රියාවක් මත පදනම්ව විවිධ වර්ගයේ pop-up modals හෝ dashboards වලට widgets එකතු කිරීම වැනි අවස්ථාවලදී Dynamic Components භාවිතා වේ. මෙය `ViewContainerRef` භාවිතයෙන් සිදු කළ හැක.
// Conceptual Example
import { Component, ViewChild, ViewContainerRef } from '@angular/core';
import { AdBannerComponent } from './ad-banner.component';
@Component({ ... })
export class AdHostComponent {
@ViewChild('adHost', { read: ViewContainerRef, static: true }) adHost: ViewContainerRef;
loadAd() {
this.adHost.clear();
const componentRef = this.adHost.createComponent(AdBannerComponent);
// You can now interact with the componentRef.instance
}
}
Angular හි animation framework එක මගින් පරිශීලක අත්දැකීම (user experience) වැඩි දියුණු කරන සංකීර්ණ සහ අලංකාර animations නිර්මාණය කිරීමට ඉඩ සලසයි. මෙය CSS animations වලට වඩා ප්රබල වන අතර component එකේ state (තත්ත්වය) මත පදනම්ව animations පාලනය කළ හැක.
මෙය භාවිතා කිරීමට `BrowserAnimationsModule` import කළ යුතුය. Animations `trigger`, `state`, `style`, `transition`, සහ `animate` වැනි functions භාවිතයෙන් `@Component` decorator එකේ `animations` metadata එක තුළ නිර්වචනය කරයි.
@Component({
...
animations: [
trigger('openClose', [
state('open', style({
height: '200px',
opacity: 1,
backgroundColor: 'yellow'
})),
state('closed', style({
height: '100px',
opacity: 0.5,
backgroundColor: 'green'
})),
transition('open => closed', [
animate('1s')
]),
transition('closed => open', [
animate('0.5s')
]),
]),
],
})
export class OpenCloseComponent {
isOpen = true;
toggle() {
this.isOpen = !this.isOpen;
}
}
පෙරනිමියෙන්, Angular යෙදුමක් Client-Side Rendered (CSR) වේ. එනම්, browser එක මගින් JavaScript load කර HTML එක ගොඩනගනු ලැබේ. මෙය SEO (Search Engine Optimization) සහ ආරම්භක කාර්ය සාධනයට (initial performance) අහිතකර ලෙස බලපෑ හැක.
Angular CLI command: ng add @angular/ssr
Internationalization (i18n) යනු යෙදුම විවිධ භාෂා සහ සංස්කෘතීන් සඳහා පහසුවෙන් අනුවර්තනය කළ හැකි වන පරිදි නිර්මාණය කිරීමේ ක්රියාවලියයි.
Angular හි ඇති built-in i18n framework එක මගින්:
මෙය `i18n` attribute එක template එකට එකතු කිරීමෙන් සිදු කරයි. ඉන්පසු CLI tool එකක් භාවිතයෙන් පරිවර්තන ගොනු (translation files) නිර්මාණය කළ හැක.
<h1 i18n>Hello World!</h1>
Angular මගින් පොදු web-application අවදානම් කිහිපයකින් ආරක්ෂා වීමට built-in ආරක්ෂණ යාන්ත්රණ සපයයි.