Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ivy] create embedded view is not added #37054

Closed
lujian98 opened this issue May 11, 2020 · 8 comments
Closed

[Ivy] create embedded view is not added #37054

lujian98 opened this issue May 11, 2020 · 8 comments
Labels
area: core Issues related to the framework runtime core: dynamic view creation needs reproduction This issue needs a reproduction in order for the team to investigate further
Milestone

Comments

@lujian98
Copy link

🐞 bug report

Affected Package

@angular/core

Is this a regression?

Yes, worked perfectly fine in v8 without Ivy. Works also without Ivy in v9.
It's interesting that in Stackblitz it works as intended, but when using Chrome/FireFox and ng serve locally it doesn't work.

Description

I try to create embedded view from template and then add the embedded view to the Content Children. However, the embedded views are not added when Ivy is on with v9.


  @ViewChild("templateToAppend", {static: true}) templateToAppend: TemplateRef;
  @ContentChildren(SomeOtherComponent, { descendants: true, read: ViewContainerRef }) someOtherComponents: QueryList;

  ngAfterContentInit() {
    this.someOtherComponents.forEach(ap => ap.createEmbeddedView(this.templateToAppend));
  }

🔬 Minimal Reproduction

https://stackblitz.com/edit/github-f2y5an?file=src%2Fapp%2Fexample%2Fexample.component.ts

https://github.com/lujian98/Angular-create-embeded-view

🔥 Exception or Error





🌍 Your Environment

Angular Version:




Angular CLI: 9.1.5
Node: 10.15.3
OS: linux x64

Angular: 9.1.6
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.5
@angular-devkit/build-angular     0.901.5
@angular-devkit/build-optimizer   0.901.5
@angular-devkit/build-webpack     0.901.5
@angular-devkit/core              9.1.5
@angular-devkit/schematics        9.1.5
@angular/cli                      9.1.5
@ngtools/webpack                  9.1.5
@schematics/angular               9.1.5
@schematics/update                0.901.5
rxjs                              6.5.5
typescript                        3.7.5
webpack                           4.42.0


Anything else relevant?

@AndrewKushnir AndrewKushnir added the area: core Issues related to the framework runtime label May 12, 2020
@ngbot ngbot bot added this to the needsTriage milestone May 12, 2020
@pkozlowski-opensource
Copy link
Member

@lujian98 I've simplified a bit your scenario here: https://stackblitz.com/edit/github-f2y5an-hmzlxt?file=src%2Fapp%2Fapp.component.ts

Still, I'm confused about the exact problem. You are saying:

It's interesting that in Stackblitz it works as intended, but when using Chrome/FireFox and ng serve locally it doesn't work.
However, the embedded views are not added when Ivy is on with v9.

Could you please be more specific? When you say "views are not added" - are they missing from the DOM (not displayed) or something else is going on?

I'm afraid that we need more info here...

@pkozlowski-opensource pkozlowski-opensource added needs reproduction This issue needs a reproduction in order for the team to investigate further and removed core: queries labels May 13, 2020
@lujian98
Copy link
Author

angular-9-ivy-on

angular-9-ivy-off

@lujian98
Copy link
Author

The embedded views are missing from the DOM when Ivy is on with "enableIvy": true.

@lujian98
Copy link
Author

embedded-views-missing-with-ivy-on
embdded-views-with-ivy-off

@pkozlowski-opensource
Copy link
Member

@lujian98 I find it surprising that stackblitz works fine but your application don't. Could you please do the following:

Thnx!

@dmitry-kostin
Copy link

dmitry-kostin commented May 15, 2020

I have a similar problem, but I have problem only with ssr rendering.
With following construction:

constructor(
private _vcr: ViewContainerRef,
)

this._vcr.createEmbeddedView(this.template)

It should create view on the same level as current component is, but it goes deeper like it doesn't see parent view;
Here is screen to compare
image
on the right: after ssr, with javascript turned off; server-render
on the left: in-browser render
So basically i have flat structure instead of nested where every node have its own view
ps not sure I'm able reproduce this

@pkozlowski-opensource
Copy link
Member

I'm going to close this one as we didn't get a reproduce scenario. Please open a new issue attaching a reproduce scenario that we could use to see the bug.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: dynamic view creation needs reproduction This issue needs a reproduction in order for the team to investigate further
Projects
None yet
Development

No branches or pull requests

4 participants