eul*_*ode 7 rxjs ionic-framework ionic2 ionic3 angular
我想用share()用subscribe(),但得到错误信息如下.最初,我开始订阅.怎么能解决这个问题?
我的目的是在订阅中执行逻辑.需要共享以防止使用异步管道进行多次调用.
类型'订阅'不能分配给'Observable'类型.
"订阅"类型中缺少"_isScalar"属性.(属性)PostDetailPage.post:Observable
this.post = this.data.getPostById(this.postId).share().subscribe(data => {
this.post = data;
},
err => {
console.log("Oops!");
})
Run Code Online (Sandbox Code Playgroud)
Gün*_*uer 15
.subscribe()返回a Subscription(允许取消订阅).
如果你想要Observable,不要使用subscribe(...).
你可以改用map(...)
this.post = this.data.getPostById(this.postId).share().map(data => {
this.post = data;
})
Run Code Online (Sandbox Code Playgroud)