I'm working on data driven app and currently I'm facing a problem of passing types into material angular dialog. I want to create reusable dialog form and need to change types for new dialog instance.
Is there a way to pass type into material dialog or into component? Or maybe there is possibility to create types in dialog itself from string passed as data?
I want to use types in dialog component like this (or similar):
export class DialogDynamicItemManagerDialog<T> {
public dialogName: string;
public items: Array<T>;
public selectedItem: T;
...
}
I've tried to pass the type like this:
OpenDynamicDialog(): void {
this.dialog.open(DialogDynamicItemManagerDialog<MyType>, {
data: {
title: 'Manage items',
items: this.items
},
});
}
but obviously it doesn't work.
I've also tried this:
OpenDynamicDialog(): void {
const dialogRef = this.dialog.open(DialogDynamicItemManagerDialog, {
data: {
title: 'Manage items',
items: this.items,
itemType: itemType
},
});
}
but I haven't find a way to change string into type in dialog afterwards.