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);