angular: View Encapsulation not working between multiple Angular 4 Apps (built with aot)
I’m submitting a … (check one with “x”)
[X] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
If i boot multiple (different) Angular 4 Apps (in different zones), the styles of each app will be adopt to all apps, because of the same css selector ( .app[_ngcontent-c0] )
Expected behavior
Every Angular 4 app should have its own css-selector
Minimal reproduction of the problem with instructions
Here is an working example with JIT-compiled Apps, both apps get different css selectors. If i build these apps with AOT, both Apps get the same css selector: http://plnkr.co/edit/fFTrK07EWBV6vSxhYaFe?p=preview
What is the motivation / use case for changing the behavior?
It should be possible to boot multiple angular 4 apps.
Please tell us about your environment:
I’m using webpack 2.3.3 with @ngtools/webpack loader (v. 1.2.13)
- Angular version: 4.0.1
- Browser: [all]
-
Language: [all]
-
Node (for AoT issues):
node --version
=
node: 6.9.4 npm: 3.10.10
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 9
- Comments: 20 (14 by maintainers)
Update: this is a regression caused by
126fda2
, landed in4.0.0-rc.2
.The
appId
was indeed used before that change:https://github.com/angular/angular/blob/6b57928d35730c3833e62581960a474b644770cd/modules/%40angular/platform-browser/src/dom/dom_renderer.ts#L39-L40
According to the documentation for APP_ID ( https://angular.io/api/core/APP_ID ) it should be prefixing the css styles but I cannot see this happening. Also when looking at the appendix “Inspecting generated CSS” from https://angular.io/guide/component-styles where you have _ngcontent-pmm-5 (I guess pmm is the app id here), this is not the case with current angular where it would only be _ngcontent-5 (pmm is missing).
Shouldn’t the APP_ID be part of the css prefix so that we could have multiple apps where styles are not overlapped?
This seems like a bug to me when looking at the documentation.
Is this going to be fixed? We have an issue where we created a WebComponent using Angular Elements and it’s interfering with our angular app.