You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ivy] ERROR Error: Template error: Can't bind to 'ngForOf' since it isn't a known property of 'div'. #32078
This repo contains the code for both the ng-packagr library and the app.
🔥 Exception or Error
core.js:4815 ERROR Error: Template error: Can't bind to 'ngForOf' since it isn't a known property of 'div'.
at createUnknownPropertyError (core.js:10180)
at elementPropertyInternal (core.js:10046)
at Module.ɵɵproperty (core.js:16508)
at ItemsComponent_Template (angular-test.js:44)
at executeTemplate (core.js:9597)
at checkView (core.js:11020)
at componentRefresh (core.js:10778)
at refreshChildComponents (core.js:9303)
at refreshDescendantViews (core.js:9202)
at checkView (core.js:11021)
Note that the ngc output contains directives: [i1.NgForOf], which is missing from the code inside of vendor-es2015.js when using the CLI. This piece of generated code would have enabled the component to use the NgForOf directive at runtime, so it being elided will prevent it from being used at runtime.
I have no clue why all of the directives get elided. The Angular compiler does generate the directives: [i1.NgForOf] code regardless of ngc vs CLI, and the emitted source file emitted from ngtsc does also contain that piece of code. So, it appears as if some transform later in the pipeline elides it from the code.
When the code inside ./src/lib is moved under ./src/app/lib and the import of ComponentsModule is changed into ./lib/components.module instead of angular-test, the code is generated properly into main-es2015.js. So this being treated as a library does affect the final bundle code.
EDIT: All of the above is not really relevant, as apparently angular-test is actually installed into node_modules and processed by ngcc 🤦♂
So, the bug is with ngcc, where the ItemsComponent's metadata has a declaration node of class ItemsComponent {} (the inner class declaration), whereas the component's scope (i.e. its registration in ComponentsModule) is registered under let ItemsComponent = class ItemsComponent {} (the outer class declaration). Therefore, the scope of the component can't be determined which results in the directives: [i1.NgForOf] to be missing from the compiled code.
Activity
JoostK commentedon Aug 10, 2019
I am seeing something very strange here. When compiling with the CLI, the following code is generated intovendor-es2015.js:However, just running ngc inside the repo results in the following:Note that the ngc output containsdirectives: [i1.NgForOf], which is missing from the code inside ofvendor-es2015.jswhen using the CLI. This piece of generated code would have enabled the component to use theNgForOfdirective at runtime, so it being elided will prevent it from being used at runtime.I have no clue why all of the directives get elided. The Angular compiler does generate thedirectives: [i1.NgForOf]code regardless of ngc vs CLI, and the emitted source file emitted from ngtsc does also contain that piece of code. So, it appears as if some transform later in the pipeline elides it from the code.When the code inside./src/libis moved under./src/app/liband the import ofComponentsModuleis changed into./lib/components.moduleinstead ofangular-test, the code is generated properly intomain-es2015.js. So this being treated as a library does affect the final bundle code.EDIT: All of the above is not really relevant, as apparently
angular-testis actually installed intonode_modulesand processed by ngcc 🤦♂JoostK commentedon Aug 11, 2019
So, the bug is with ngcc, where the
ItemsComponent's metadata has a declaration node ofclass ItemsComponent {}(the inner class declaration), whereas the component's scope (i.e. its registration inComponentsModule) is registered underlet ItemsComponent = class ItemsComponent {}(the outer class declaration). Therefore, the scope of the component can't be determined which results in thedirectives: [i1.NgForOf]to be missing from the compiled code.fr0 commentedon Aug 28, 2019
Related: ng-packagr/ng-packagr#1278
angular-automatic-lock-bot commentedon Oct 13, 2019
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.