# Angular 消息推送
1.service
import {Subject} from 'rxjs'
public checkLoading = new Subject<any>();
// 通道
checkLoadings = val => {
// 发布
this.checkLoading.next(val);
}
2
// 发布过程
this.logisticsService.checkLoadings(this.logisticsService.isLoadtime+1)
3
// 订阅
constructor(
) {
this.loadSubscription = this.logisticsService.checkLoading.subscribe(res => {
this.loading = res
this.logisticsService.isLoadtime = this.loading
console.log(this.logisticsService.isLoadtime)
});
}
4
// 取消订阅
this.loadSubscription.unsubscribe()
← Web 前端如何Mock数据 →