I have created a dialog using Material Design for Angular. In the original example there was only one field, which was bound with one parameter in parent view. I want to create a dialog, that gathers more than just one parameter and return these parameters back to the parent component, so I can post it to my API.
How it looks now:
<h1 mat-dialog-title>Create</h1>
<div mat-dialog-content>
<p>Fill in a new company name</p>
<mat-form-field>
<input matInput [(ngModel)]="data.name">
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">Cancel</button>
<button mat-button [mat-dialog-close]="data.name" cdkFocusInitial>Ok</button>
</div>
What I want to achieve:
<h1 mat-dialog-title>Create</h1>
<div mat-dialog-content>
<p>Fill in a new person name</p>
<mat-form-field>
<input matInput [(ngModel)]="data.name">
<input matInput [(ngModel)]="data.surname">
<input matInput [(ngModel)]="data.email">
<input matInput [(ngModel)]="data.mobile">
...
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">Cancel</button>
<button mat-button [mat-dialog-close]="WHAT DO I ENTER HERE?" cdkFocusInitial>Ok</button>
</div>
When I removed the [mat-dialog-close] property, the data never came back to the component and couldn't be sent to API. Could you advise on how do I pass back these multiple values?
[mat-dialog-close]="data"- Roberto Zvjerković