-
Notifications
You must be signed in to change notification settings - Fork 21
Angular 14
JL edited this page Feb 15, 2023
·
2 revisions
No need to declare components into NgModule anymore.
- Instead use
standalone: true
into@Component
arguments - Quote from angular.io : "Existing applications can optionally and incrementally adopt the new standalone style without any breaking changes."
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
@Component({
selector: 'sample',
standalone: true, // <-------------- HERE
imports: [
// import standalone Components, Directives, and Pipes
CommonModule // and NgModules
],
template: `
<div>{{name}}</div>
`
})
export class SampleComponent {
name = "Angular 14";
}
Types can now be set to FormControls when defining a FormGroup, providing type checking.
var contactForm = new FormGroup({
name: new FormControl<string>('', { nonNullable: true }),
email: new FormControl<string>('', { nonNullable: true }),
contactNumber: new FormControl<number>(0, { nonNullable: false })
});
It's possible to set the current page title in the routes definition instead of calling Title service.
The "title" is the title of the web page that appear in the browser tab or in the browser history
constructor(private titleService: Title) {
titleService.setTitle('Shanoir Home Page');
}
{
path: 'home',
component: HomeComponent,
title: 'Shanoir Home Page'
},
A Component member doesn't have to be public
to be visible in the html template anymore, it can now be protected
.*
Angular 14 also includes support for the latest TypeScript 4.7 release and now targets ES2020 by default, which allows the CLI to ship smaller code without paring down features.
More warnings and errors in the template page from your IDE.