如何在弹出窗口中使用相同的服务实例?
我正在尝试使用通信服务在不同角度组件之间发送一些数据。但是当子组件在弹出窗口中打开时,我遇到了一个问题。因为它本身就是一个单独的角度应用程序。因此它采用了不同的服务实例,因此我无法发送数据。
这是我的通讯服务。
import { Injectable } from "@angular/core";
import { Subject } from "rxjs";
@Injectable()
export class CommunicatingService {
private subject = new Subject<any>();
sub = this.subject.asObservable()
constructor() {}
nextSub(data: any) {
this.subject.next(data)
}
}
I am trying to use a communication service to send some data between different angular components. But I am facing an issue when the child component is opened inside a pop-up window. Since it is a separate angular app itself. So it's taking a different instance of the service and thus I am unable to send data.
This is my communication Service.
import { Injectable } from "@angular/core";
import { Subject } from "rxjs";
@Injectable()
export class CommunicatingService {
private subject = new Subject<any>();
sub = this.subject.asObservable()
constructor() {}
nextSub(data: any) {
this.subject.next(data)
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论