I don't even know if this is possible in TypeScript, but I'm trying to inherit a function from a Class, like this:
import {Component, AfterViewInit, ElementRef} from 'angular2/core';
@Component({})
class Class1 {
name: string;
constructor(private el: ElementRef) {}
private setName() {
this.name = "test";
}
ngAfterViewInit() {
this.setName();
}
}
@Component({
selector: 'test'
})
export class Class2 extends Class1 {
ngAfterViewInit() {
super.ngAfterViewInit();
console.log(this.name);
}
}
but I'm getting the following error in console when calling the setName() function:
EXCEPTION: TypeError: this.el is undefined
Why isn't this working?
this.name = this.el.nativeElement.firstChild;