简体   繁体   English

如何在 Mat-Dialog Angular 中传递数组

[英]How to pass an array in Mat-Dialog Angular

How to pass array in mat dialog?如何在垫子对话框中传递数组? I have 2 components one is the dialog and the other is my main so once I input a qty and open the dialog the row will be populated by 2 so when i tried to input and click the button it will display it to my main component how to achieve that?我有 2 个组件,一个是对话框,另一个是我的主要组件,所以一旦我输入一个数量并打开对话框,该行将由 2 填充,所以当我尝试输入并单击按钮时,它将显示它到我的主要组件如何实现这一目标?

here's what I did这就是我所做的

https://stackblitz.com/edit/mat-dialog-example-w3ojzi https://stackblitz.com/edit/mat-dialog-example-w3ojzi

        You have to pass data from your alert-dialog.component.ts sameInmemory method like: 
        
             saveInmemory() {
                this.http.post('api/users', this.fg.value).subscribe((res) => {
                  this.dialogRef.close(res);
                });
              }

    This data will be received in you result inside your openAlertDialog 
    method,from here you can patch value in your Form Controls 

Hope this help, Thanks!希望对您有所帮助,谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM