Cannot create property 'ngIf' on number in Angular 8
See original GitHub issueπ bug report
Affected Package
Is this a regression?
I canβt tell exactly, this app is freshly written in angular 8, but Iβve never encountered such issues in previous versions.
Description
ngIf behaves unexpectedly, I have a complex component which consists of multiple smaller components, but still template reaches up to 70 lines. There I have bindings on every component and at the top of the template I have this code:
<h2>
<span *ngIf="hasBasicInfo(); else missing">
{{ form.value[basicInfoFormControlName][nameControlName] }}
</span>
<ng-template #missing>MISSING</ng-template>
</h2>
This works perfectly fine until I changed one of subcomponents, which in template looked like this:
<st-classification-in-frameworks
[solution]="solution"
[selectedSegments]="solution.segments"
(segmentSelectionChange)="updateSolutionOnSegmentSelection($event)"
></st-classification-in-frameworks>
Basically I just deleted [selectedSegments]="solution.segments"
like and removed an @Input()
in that component.
As soon as I do that I get error: Cannot create property 'ngIf' on number 871548
It complains exactly about that ngIf
I mentioned above. I believe this is a bug in the core rendering(I am using Ivy), because for some reason instance
in setInputsForProperty
is evaluated as a number, and not only that, sometimes I am also getting boolean value. This appears to be pretty random, because when I remove else part from that ngIf
it works again, or if I move it another place. I donβt see how my code can be wrong to break it. But I also donβt have knowledge of how Ivy works from inside to understand why this happens.
π¬ Minimal Reproduction
Unfortunately I was not able to reproduce this in any other setup, this issue seems to be pretty specific and quite random.
π₯ Exception or Error
core.js:7187 ERROR TypeError: Cannot create property 'ngIf' on number '871548'
at setInputsForProperty (core.js:13500)
at elementPropertyInternal (core.js:12390)
at Module.Ι΅Ι΅property (core.js:16528)
at SolutionComponent_Template (solution.component.html:3)
at executeTemplate (core.js:12007)
at checkView (core.js:13358)
at componentRefresh (core.js:13122)
at refreshChildComponents (core.js:11710)
at refreshDescendantViews (core.js:11616)
at renderComponentOrTemplate (core.js:11985)
π Your Environment
Angular Version:
Angular CLI: 8.0.0
Node: 10.16.0
OS: darwin x64
Angular: 8.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.800.0
@angular-devkit/build-angular 0.800.0
@angular-devkit/build-optimizer 0.800.0
@angular-devkit/build-webpack 0.800.0
@angular-devkit/core 8.0.0
@angular-devkit/schematics 8.0.0
@ngtools/webpack 8.0.0
@schematics/angular 8.0.0
@schematics/update 0.800.0
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0
Anything else relevant?
One more detail is that the error doesnβt happen on initial load of the component. First time it renders correctly, however if hasBasicInfo
returns false, it does not render the missing
template. Then I click on something that triggers change detection and that error appears. What is interesting is that it only appears twice(for ngIf and ngIfElse, which I could while trying to debug) with different property and third time it actually runs.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Iβll try to create an app where this would be reproducible when I have time. Hopefully this week.
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.