Loading episodes…
0:00 0:00

Angular 9.1 displayBlock CLI Component Generator Option by Example

00:00
BACK TO HOME

Angular 9.1 displayBlock CLI Component Generator Option by Example

10xTeam March 26, 2020 1 min read

In this article, we’ll learn about the new displayBlock option for the Angular 9.1 CLI component generator.

When you use the CLI to generate an Angular component, it will be displayed inline by default using the CSS inline property, as this is the default display for most DOM elements.

Displaying Angular Components with the display: block CSS style

More often than not, you’ll need display your components with the display: block CSS style.

Instead of changing this manually for each new component you generate, you now have the option to set it automatically when using the CLI thanks to the displayBlock introduced in Angular 9.1.

Using Angular 9.1 CLI displayBlock by Example

This is how you use this option when generating a new Angular component:

ng generate component home --displayBlock

You can also make display:block by default by setting theschematics.@schematics/angular:component.displayBlock key in your angular.json to true, or also run the following command in your terminal:

ng config schematics.@schematics/angular:component.displayBlock true

Join the 10xdev Community

Subscribe and get 8+ free PDFs that contain detailed roadmaps with recommended learning periods for each programming language or field, along with links to free resources such as books, YouTube tutorials, and courses with certificates.

Audio Interrupted

We lost the audio stream. Retry with shorter sentences?