Can anyone explain why I keep receiving an undefined error?
export abstract class BaseEditorComponent implements IPropertyEditor, OnDestroy {
@Input()
public element: BpmnJS.IRegistryElement;
--more code here
export class CommonPropertiesEditorComponent extends BaseEditorComponent {
constructor(
) {
super();
}
public get elementId(): string {
return this.element.id;
}
export class ExclusiveGatewayEditorComponent extends CommonPropertiesEditorComponent implements OnInit {
public model: IUserTaskDef;
public outGoing: Sequences[];
constructor(
private service: ExclusiveGatewayService
) {
super();
this.model = {} as any;
this.outGoing = this.getOutGoingSequences();
}
public getOutGoingSequences(): Sequences[] {
return this.service.getOutgoingSequences(this.elementId); //This is undefined.
}
TypeError: Cannot read property 'id' of undefined at ExclusiveGatewayEditorComponent.get [as elementId] (common-properties-editor.component.ts:16) at ExclusiveGatewayEditorComponent.push../src/app/properties/editors/gateways/exclusive-gateway/exclusive-gateway-editor.component.ts.ExclusiveGatewayEditorComponent.getOutGoingSequences (exclusive-gateway-editor.component.ts:27) at new ExclusiveGatewayEditorComponent (exclusive-gateway-editor.component.ts:22) at createClass (core.js:21148) at createDirectiveInstance (core.js:21027) at createViewNodes (core.js:29387) at createRootView (core.js:29301) at callWithDebugContext (core.js:30309) at Object.debugCreateRootView [as createRootView] (core.js:29819) at ComponentFactory_.push../node_modules/@angular/core/fesm5/core.js.ComponentFactory_.create (core.js:20506)
When I input the same function into the HTML page, it works perfectly and displays the value of element.id
<input class="form-control" type="text" name="txtId" [(ngModel)]="elementId" readonly>