ACS-8198 add injection to component data

This commit is contained in:
Darya Balvanovich
2024-06-13 00:00:22 +02:00
committed by Darya Blavanovich
parent d8634c901a
commit f1fab8700a
5 changed files with 36 additions and 2 deletions

View File

@@ -79,6 +79,30 @@ function openDialog() {
}
```
To use dialog with provided component as a content `componentData` should be passed as data parameter. Inside component `DIALOG_COMPONENT_DATA` should be injected.
```ts
//...
function openDialog() {
const data: DialogData = {
title: 'Dialog title',
contentComponent: ExampleDialogComponent,
componentData: { nodeId: 'nodeId', name: 'node name' } // any data can be passed
};
this.dialog.open(DialogComponent, { data });
}
```
in `ExampleDialogComponent`:
```ts
export class ManageHoldsDialogComponent {
inputs = inject(DIALOG_COMPONENT_DATA); // inputs = { nodeId: 'nodeId', name: 'node name' }
}
```
Note that **fixed width** may be provided which will work correctly on smaller screens. But don't specify any values for **height**, as this may break the scrollable content and hide the buttons.
To display the design well, it is necessary to provide no more than 2 additional buttons.

View File

@@ -26,6 +26,7 @@ interface DialogData {
descriptionTemplate?: TemplateRef<any>;
headerIcon?: string;
additionalActionButtons?: AdditionalDialogActionButton[];
componentData: any;
}
```
@@ -48,6 +49,7 @@ interface DialogData {
| actionsTemplate | `TemplateRef<any>` | | Inserts a template styled on the left. Should be used for additional `mat-button` style buttons. (optional) |
| descriptionTemplate | `TemplateRef<any>` | | Inserts a description template. (optional) |
| additionalActionButtons | `AdditionalDialogActionButton[]` | | Inserts additional base-styled buttons into the action bar on the left. (optional) |
| componentData | `any` | | Data that injected in contentComponent. (optional) |
## See also