Closed garsuga closed 3 years ago
Thanks for the issue. We are still looking into this, but using ng-template
instead of a div
should be a safe workaround for now.
Thanks for the issue. This ended up being a bug in Angular that Mike opened an issue for. The fix has been merged and is available in a pre-release version of Angular 11.1 if you are interested in trying it out.
I am going to close this issue - thanks!
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Ionic version:
[ ] 4.x [x] 5.x
I'm submitting a ...
[x] bug report [ ] feature request
Current behavior:
Calling ViewContainerRef.createComponent and ViewContainerRef.clear has no effect on the page if the element which owns the ViewContainerRef is a direct child of "ion-content"
Expected behavior:
I am not sure if this is unintended but there is no warning produced and I could not find any mention of this behavior in the documentation.
Steps to reproduce:
Generate a new app from the 'blank' template. Create a new component and declare it in the 'home' module. Make a "div #testElement" tag directly inside the 'home' page template's "ion-content" element and declare a ViewChild to access the "div" element's ViewContainerRef in the 'home' page code. Make a button on the 'home' page that makes the related calls to createComponent or clear. No new elements appear on the page and no elements are cleared when the button is pressed. The intended result works if you surround the "div #testElement" in another "div" element.
Related code: home.page.ts
home.page.html that produces bug
home.page.html that produces the intended result
TestComponent is a blank component generated with
ionic generate component home/test
and declared in the HomeModuleIonic info: