How to Fix Angular Control Flow Formatting in VS Code

If you’ve used VS Code’s “Format Document” right-click option to format an Angular HTML template, you may have noticed that it doesn’t indent things the way you’d expect.

Example: 

Badly indented HTML

In the code above, the option tag should be indented within the @for loop.

There’s been a fix for this. 😊 If you edit the settings.json file in the .vscode folder, and add this, it will work:

VS Code settings fix

 After adding this to settings.json and using the “Format Document” option, it formats correctly.

Corrected HTML formatting


Comments

Popular Posts

Roku OS 15.0.4 Breaks HEVC Decoding

How to Get Norton Security Suite Firewall to Allow Remote Desktop Connections in Windows

The Cause and Solution for the "System.Runtime.Serialization.InvalidDataContractException: Type 'System.Threading.Tasks.Task`1[YourTypeHere]' cannot be serialized." Exception

Setting Default Values in an Angular Reactive Form

How to Determine if a Column Exists in a DataReader