mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
730684b9ce
This fixes an issue where when removing NgStyle from the imports array of a component, an extra trailing comma would be left behind if it was the last element in that component`.
ngStyle to style migration
This schematic helps developers to convert ngStyle directive usages to style bindings where possible.
How to run this migration?
The migration can be run using the following command:
ng generate @angular/core:ngstyle-to-style
By default, the migration will go over the entire application. If you want to apply this migration to a subset of the files, you can pass the path argument as shown below:
ng generate @angular/core:ngstyle-to-style --path src/app/sub-component
How does it work?
The schematic will attempt to find all the places in the templates where the directive is used and check if it can be converted to [style].
Example:
<!-- Before -->
<div [ngStyle]="{'background-color': 'red'}">
<!-- After -->
<div [style]="{'background-color': 'red'}"></div>
</div>