问题
I have defined a behavior subject:
component.ts
bsub1: BehaviorSubject<Array<any>> = new BehaviorSubject(null);
And called next() on it:
html:
<button (click) = getData()>Data</button>
component.ts:
getData() {
getSomething(value, bsub1);
}
service.ts
getSomething(value, _observable) {
//do something
_observable.next(retun)
somevariable.map(p => {
return { "a": value1, "b": value2 }
});
}
And made a subscription:
component.ts
ngOnInit() {
bsub1.subscribe(list=>{
console.log("subscribed to bsub1")
});
}
But my code does not reach upto subscription after call to getSomething(). It reaches there when component loads but when next() is called after that it does not subscribe. this happen only in IE 11 whereas in edge, chrome and firefox it is working.
Can someone explain me this behavior?
来源:https://stackoverflow.com/questions/51673368/observable-subscription-does-not-work-when-written-in-ngonit-in-ie