Science, asked by joeljoseph2196, 11 months ago

How to preserve whitespace in Angular?

Answers

Answered by AgarwalSahb
0

Angular 4.4.1 dropped on September 18th and inside it there is a new flag called “preserveWhitespaces”. This flag will allow you to remove whitespace in your generated code reducing the code size and speed of component creation. It is noted that it can break your component if it relies on whitespace for things like those ascii art components you have. Because of this, the flag is set to true by default but given the gains I can see it becoming the default in the future. You can configure it manually or on a component-by-component basis. For globally do:  platformBrowserDynamic().bootstrapModule(AppModule, {  preserveWhitespaces: false });  or by component:  @Component({  selector: ‘avatar’,  templateUrl: ‘./avatar.component.html’,  preserveWhitespaces: false // <<< This }) export class AvatarComponent { … }  There is also a new directed called `ngPreserveWhitespaces` where you can preserve whitespace in template fragments which can be used like:  <div ngPreserveWhitespaces>hi !+! panda</div>  Its nothing ground breaking but gains are gains!

Similar questions