I've encountered an issue with my TypeScript model while using it in a cast. The model does not load properly when the application is running, preventing me from accessing any functions within it.
Model
export class DataIDElement extends HTMLElement {
get dataID(): number {
var attributes: NamedNodeMap = this.attributes;
var dataIDAttribute: Attr = attributes.getNamedItem("data-id");
if (!dataIDAttribute) {
//throw error
}
var value: number = Number(dataIDAttribute.value);
return value;
}
}
Angular Component (Where model is being imported)
import { DataIDElement } from '../../models/dataIdElement';
export class PersonComponent
{
personClicked(event: KeyboardEvent): void {
var element: DataIDElement = <DataIDElement>event.target;
// This code always returns undefined (model isn't loaded)
var personID: number = element.dataID;
}
}