I have an implementation where parent wants to pass certain data to child component via the use of @Input
parameter available at the child component. However, this
You have two options here.
1) You can use an *ngIf
on the child in case the child does not need to be displayed when its Input is empty.
//passing parameter
//not willing to passing any parameter
2) In case the child should get displayed without any input, you can use a modified setter to check for the presence of input variables`
In the child.ts:
private _optionalObject: any;
@Input()
set optionalObject(optionalObject: any) {
if(optionalObject) this._optionalObject = optionalObject;
}
get optionalObject() { return this._optionalObject; }