I'm at my wit's end trying to figure this out. I've searched high and low, but I just can't seem to understand why this error persists.
My code looks something like this:
parent.html
<child-1 [(type)]="type"></child-1>
parent.ts
type = 0;
getTypeToOtherthings() {
console.log(type);
}
child-1.html
<child-2 [(type)]="type">
child-1.ts // acting as a connection between parent and child-2
_type: number;
@Input() set type(val: number) {
this.typeChange.emit(val);
this._type= val;
}
get type() {
return this._type;
}
@Output() typeChange: EventEmitter<number> = new EventEmitter<number>();
child-2.html
(some HTML)
child-2.ts
_type: number;
@Input() set type(val: number) {
this.typeChange.emit(val);
this._type= val;
}
get type() {
return this._type;
}
@Output() typeChange: EventEmitter<number> = new EventEmitter<number>();
/*Trying to change the Type variable in child-2, attempted in ngOnInit (and various other lifecycle hooks with no success using Promise, ChangeDetectorRef, etc.
Everything seems fine, yet the error still persists)*/
ngOnInit() {
this.type = 2;
}
At this point, I'm nearly ready to throw in the towel.