admin管理员组文章数量:1026938
I have an mat dialog ponent in my project as I press Confirm button I call
onCloseConfirm(data) {
this.thisDialogRef.close('Confirm');
console.log("conf data", data);
}
in my parent I subscribe to passed data (in my Case 'Confirm');
dialogRef.afterClosed().subscribe(result => {
console.log(`Dialog closed: ${result}`);
});
What I would like to do is to pass data
also. So I would like to pass the 'Confrim'
message + data
both. Is it possible?
I have an mat dialog ponent in my project as I press Confirm button I call
onCloseConfirm(data) {
this.thisDialogRef.close('Confirm');
console.log("conf data", data);
}
in my parent I subscribe to passed data (in my Case 'Confirm');
dialogRef.afterClosed().subscribe(result => {
console.log(`Dialog closed: ${result}`);
});
What I would like to do is to pass data
also. So I would like to pass the 'Confrim'
message + data
both. Is it possible?
1 Answer
Reset to default 4You can pass anything to the close
method, so you could pass something like this:
onCloseConfirm(data) {
this.thisDialogRef.close({
message: 'Confirm',
data
});
console.log("conf data", data);
}
And then, in the afterClosed handler:
dialogRef.afterClosed().subscribe(result => {
console.log(`Dialog closed: ${result.message}`, result.data);
});
I have an mat dialog ponent in my project as I press Confirm button I call
onCloseConfirm(data) {
this.thisDialogRef.close('Confirm');
console.log("conf data", data);
}
in my parent I subscribe to passed data (in my Case 'Confirm');
dialogRef.afterClosed().subscribe(result => {
console.log(`Dialog closed: ${result}`);
});
What I would like to do is to pass data
also. So I would like to pass the 'Confrim'
message + data
both. Is it possible?
I have an mat dialog ponent in my project as I press Confirm button I call
onCloseConfirm(data) {
this.thisDialogRef.close('Confirm');
console.log("conf data", data);
}
in my parent I subscribe to passed data (in my Case 'Confirm');
dialogRef.afterClosed().subscribe(result => {
console.log(`Dialog closed: ${result}`);
});
What I would like to do is to pass data
also. So I would like to pass the 'Confrim'
message + data
both. Is it possible?
1 Answer
Reset to default 4You can pass anything to the close
method, so you could pass something like this:
onCloseConfirm(data) {
this.thisDialogRef.close({
message: 'Confirm',
data
});
console.log("conf data", data);
}
And then, in the afterClosed handler:
dialogRef.afterClosed().subscribe(result => {
console.log(`Dialog closed: ${result.message}`, result.data);
});
本文标签: javascriptPass several data from Mat Dialog Angular 4 back to parentStack Overflow
版权声明:本文标题:javascript - Pass several data from Mat Dialog Angular 4 back to parent - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745654200a2161500.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论