Home > database >  Why do bindings type comments appear in Angular?
Why do bindings type comments appear in Angular?

Time:01-20

I would like to know why comments like these appear in Angular and if there is a way to hide them?

</div>
<!--bindings={
  "ng-reflect-ng-if-else": "[object Object]"
}-->
<div>

enter image description here

CodePudding user response:

Those allow development tools like the DevTools Chrome extension to help you debug your application. They're not present when you build for production. There's no reason (and no way) to remove them in debug mode.

You can see this in action with this StackBlitz. Notice how the comment references why the element is being shown (an ngIf binding is true or false).

The ng-reflect attributes can be disabled by enabling production mode. See this answer for more information about that.

  • Related