Closed
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/elements
Is this a regression?
No.
Description
When using an Angular Element as a custom element, a component @Input
cannot be initialized to false
(or other falsy value) via setting the element's property value.
🔬 Minimal Reproduction
Stackblitz that shows failure to initialize both "false" (for boolean) and 0 (for number): https://stackblitz.com/edit/angular-elements-test-input-bindings
I debugged this and this if
condition appears to be causing it (component-factory-strategy.ts#L168):
if (initialValue) {
this.setInputValue(propName, initialValue);
} else {
// Keep track of inputs that were not initialized in case we need to know this for
// calling ngOnChanges with SimpleChanges
this.uninitializedInputs.add(propName);
}
This is treating any "falsy" value as uninitialized, which is incorrect.
🔥 Exception or Error
There is no error, the boolean false
input value is not set to the component input.
🌍 Your Environment
Angular Version:
Angular CLI: 7.3.9
Node: 10.14.2
OS: darwin x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, elements
... forms, http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.13.9
@angular-devkit/build-angular 0.13.9
@angular-devkit/build-optimizer 0.13.9
@angular-devkit/build-webpack 0.13.9
@angular-devkit/core 7.3.9
@angular-devkit/schematics 7.3.9
@angular/cdk 7.2.2
@angular/cli 7.3.9
@ngtools/webpack 7.3.9
@schematics/angular 7.3.9
@schematics/update 0.13.9
rxjs 6.4.0
typescript 3.2.4
webpack 4.29.0
Activity
[-]Can't initialize Angular Element with a `false` element property value[/-][+]Can't initialize Angular Element with a "falsy" element property value[/+]fix(elements): handle falsy initial value (angular#31604)
fix(elements): handle falsy initial value (#31604)
fix(elements): handle falsy initial value (angular#31604)
angular-automatic-lock-bot commentedon Sep 15, 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.