Currently facing an issue with building an Icon
component that should inherit properties from a base class. Strangely, upon instantiation of the Icon
, none of the properties from super
are present, and the __proto__
property is not properly set.
Despite running a simplified version of the code on CodePen where it works as expected: CodePen Example
The problem arises within Angular 2 context, as the inherited property turns out to always be undefined
.
BaseComponent.ts
export abstract class BaseComponent {
constructor() {
this.baseImagePath = '/Assets/Images';
}
baseImagePath: string;
}
Icon.ts
import {Component, Input} from 'angular2/core';
import {BaseComponent} from '../baseComponent';
@Component({
selector: 'lib-icon',
templateUrl: 'app/components/icon/icon.tmpl.html'
})
export class Icon extends BaseComponent {
@Input() icon: string;
constructor() {
super();
this.baseImagePath += '/icons/';
}
getSrc() {
return `${this.baseImagePath}${this.icon}`;
}
}
Even after attempting to move the line this.baseImagePath += '/icons/'
into ngOnInit
just in case - the issue persists with the value remaining undefined.
If you have any insight on what I may be overlooking, your assistance would be greatly appreciated.