1
我已经放在一个简单的例子,我相信应该工作..但它不:( 我需要帮助了解我的'在做错误的。从可观察主题推/置值,不更新订阅可观察
@Component({
templateUrl: 'sandbox.template.html'
})
export class SandBoxPage implements OnInit {
dataSubject: Subject<string> = Subject.create();
data$: Observable<string>;
constructor(private platform: Platform) {
this.data$ = this.dataSubject
.asObservable()
.startWith("First value in the observable");
}
onClick() {
console.log("onClick()");
this.dataSubject.next(Date.now + " value");
}
ngOnInit() {
console.log("ngOnInit()");
this.data$.subscribe((v) => {
console.log("new value", v);
}, (err) => {
console.log("Error", err);
});
}
}
我必须挂在onClick()
但在我的console.log认购不火,它只有在开始的startsWith
值触发一次按钮。
哇。只是......哇。多么微妙的头痛。谢谢! – Matt
@Matt我们都在那里:) – echonax