Can TypeScript and Angular (6) be used in conjunction for this question?
Here is a model class example:
export class DropData {
private readonly _originType: Component;
private readonly _originRow: number;
private readonly _originCol: number;
private readonly _originComp: number;
constructor(originType: Component, originRow: number, originCol: number, originComp: number) {
this._originType = originType;
this._originRow = originRow;
this._originCol = originCol;
this._originComp = originComp;
}
export class Component {
id: number;
component: string;
constructor(id: number, component: string) {
this.id = id;
this.component = component;
}
}
Is there a way to initialize this from an HTML template? The attempted method is shown below:
<div mwlDraggable
[ghostElementTemplate]="dragging"
[dropData]="new DropData(new PageComponent(component.id, componentManager.getComponentSimpleName(component.id)),rowIndex, colIndex, compIndex)"
dragActiveClass="drag-active">
<ng-template
[appComp]="componentManager.getComponentSimpleName(component.id)"
[id]="component.id">
</ng-template>
</div>
(EDIT: The 'componentManager.getComponentSimpleName(component.id)' function, which returns a string, was accidentally omitted and should be included.)
EDIT2 The error encountered when accessing the page:
Uncaught Error: Template parse errors:
Parser Error: Unexpected token 'DropData' at column 5 in [new DropData(new
PageComponent(component.id, componentManager.getComponentSimpleName(component.id)),rowIndex, colIndex, compIndex)] in ng:///AppModule/PageFoundationComponent.html@80:21 (" <div mwlDraggable
[ghostElementTemplate]="dragging"
[ERROR ->][dropData]="new DropData(new
PageComponent(component.id, componentManager.getComponentSimpleName(comp"): ng:///AppModule/PageFoundationComponent.html@80:21