Angular 18 has come up with lot of new features such as Change Detection using Signals,Routes redirect function,Developer Tooling Enhancements,Signals,Deferrable Views and built in control flow,Server Side Rendering improvements,Internationalization.
Top new features of Angular 18:
one of the most interesting features in angular 18 is signals.The signals play a vital role in state management.Here zoneless change detection is being used.
Now go to app config file and include provideexperimentalzonelesschangedetection in providers section.Next go to angular.json file and remove
zone.js from polyfills array.Now restart the server.Now check whether zone library is used in browser.
bootstrapApplication(App, {
providers: [
provideExperimentalZonelessChangeDetection()
]
});
The RedirectTo is now can be used as function and not just a string.For eg:-
App.routes.ts
Reads URL information:
export const routes:Routes=[
{
path:'userprofile',
redirectTo:()=>{
return '/user';
},
pathMatch='full'
}]
}
You can see UrlInfo in the terminal.
path:'userprofile',
redirectTo:(urlInfo)=>{
console.log(urlInfo)
return '/user';
},
pathMatch='full'
Angular DevTools is a browser extension that provides debugging and profiling capabilities for Angular applications. When you open the extension, you will find 2 tabs
The deferrable views allows components to be loaded on demand, makes application performance better.For example, you can restrict a component to be loaded on init.Instead you can load the component on demand. The other features which are used along with 'defer':-
Server side rendering requires node server to deploy the project.It is useful when your site is showing dynamic content.You can disable serverside
rendering in config file using 'Prerender' option .
The enhancement done in server side rendering are ,
"architect": {
"build": {
"options": {
"server": "src/main.server.ts",
"prerender": false,
"ssr": {
"entry": "server.ts"
}
}
Angular 18 provides new APIs for internationalization and tooling support.This helps apps content to be viewed in their own languages.
The internationalization provides users to enjoy the benefit of viewing their application on different languages