angular5订阅之一 Subject()

在 service里面 

public isShowSubject: Subject<Object> = new Subject();
通过service 
this.Service.isShowSubject.next(数据);
在其他组件中使用 
this.Service.isShowSubject.subscribe((data) => {
  console.log(data);
}

猜你喜欢

转载自www.cnblogs.com/aisiqi-love/p/10142994.html