Angular 6-7 ViewEncapsulation.emulated prefix


Is it possible to prefix or postfix the tags generated when ViewEncapsulation.Emulated is enabled in an angular 2-7 component its now like [_ngContent-C0] is there a setting to let it do something like [_ngContent-C0-myApp] so adding a custom string to the generated class tag?

Best regards


If you check angular source code related to dom rendering, , you will see that this attribute has fixed pattern and does not accept external settings. So my guess is, no, you cannot, at least for the current versions. and most likely, it will never expose such an option as it might result in non-unique identifiers which will break encapsulation.

update: componentId is the id defined in component definition, you can check, and you can see it is auto-incremented.

Answered By – ABOS

Answer Checked By – Jay B. (AngularFixing Admin)

Leave a Reply

Your email address will not be published.