Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 将md输入值从对话框传递到父组件函数_Angular_Modal Dialog_Parameter Passing_Angular Material2 - Fatal编程技术网

Angular 将md输入值从对话框传递到父组件函数

Angular 将md输入值从对话框传递到父组件函数,angular,modal-dialog,parameter-passing,angular-material2,Angular,Modal Dialog,Parameter Passing,Angular Material2,我在对话框窗口中有一个md输入字段(该对话框是一个子组件)。我需要将此值作为父组件中函数的参数传递。 如何操作?定义一个共享的.service,它将输入值传递给父组件: import {Injectable } from '@angular/core'; import { Subject } from 'rxjs'; @Injectable() export class SharedService{ public triggerParentMethod: Subject<strin

我在对话框窗口中有一个
md输入
字段(该对话框是一个子组件)。我需要将此值作为父组件中函数的参数传递。
如何操作?

定义一个
共享的.service
,它将输入值传递给父组件:

import {Injectable } from '@angular/core';
import { Subject } from 'rxjs';

@Injectable()
export class SharedService{
   public triggerParentMethod: Subject<string> = new Subject<string>();
}
将您的
绑定到某些
[(ngModule)]

您可以从对话框中发出该输入值,如下所示:

this.sharedService.triggerParentMethod.next(this.someField);

链接到。

您测试过我提供的解决方案吗?
this.sharedService.triggerParentMethod.next(this.someField);