I have this component in my template:
<vector-editor #scaleControl
[x]="scaleX"
[y]="scaleY"
[z]="scaleZ" >
</vector-editor>
The vector-editor
has the following structure:
export class VerticeControlComponent implements OnInit
{
@Input() x: number;
@Input() y: number;
@Input() z: number;
...
}
In my application I grab a reference to the #scaleControl
using
@ViewChild('scaleControl') scaleControl: ElementRef;
Now if I output scaleControl
to the console I get this result:
As can be seen, the reference is not null and all the properties of my component are there. I want to access those properties, but in code the actual type of the scaleControl
is ElementRef
and not VectorEditorControl
as seen in the output. Because of this, TypeScript doesn't me allow to use this.scaleControl.x
.
I also tried to cast ElementRef
like this
var temp = <VectorEditorControl>this.scaleControl
but I get an error telling me that I cannot cast ElementRef
to VectorEditorControl
In the end, I tried to access this.scaleControl.nativeElement
but it's undefined...
What am I missing here?