Do you use standalone components?
Updated by Anton Polkanov [SSW] 1 year ago. See history
123
<introEmbed body={<> [Standalone components](https://angular.io/guide/standalone-components) were introduced in Angular 14 and should be used instead of modules for every new component you create. </>} /> There is a number of advantages of using standalone components over modules as they: 1. Reduce the amount of boilerplate code. They don't belong to a particular NgModule and don't have to be declared, so can be used in any part of the application 2. Streamline component creation 3. Allow to lazy-load the component without using an NgModule 4. Flatten the learning curve for new developer as the concept of NgModules is off the table To make a component standalone, set `standalone: true` ```javascript @Component({ standalone: true, selector: "my-component", imports: [FooComponent], template: ` ... <foo-component></foo-component> `, }) export class MyComponent { // component logic } ``` <!--endintro-->
Categories
Related rules
Need help?
SSW Consulting has over 30 years of experience developing awesome software solutions.