[英]angular2 viewing observable with async pipe not rendering
I am using @ngrx/store
and I am grabbing a slice of the state from the store. 我正在使用
@ngrx/store
,正在从商店中获取状态的一部分。
I have a component that wants to display that slice. 我有一个想要显示该切片的组件。 However, with the
{{ obs$ | async}}
但是,使用
{{ obs$ | async}}
{{ obs$ | async}}
present in the template, the entire template is not rendered. 模板中存在
{{ obs$ | async}}
,则不会呈现整个模板。 If I remove the {{ obs$ | async }}
如果我删除
{{ obs$ | async }}
{{ obs$ | async }}
then SLICE:
is rendered. {{ obs$ | async }}
然后呈现SLICE:
Any idea on why this is the case or how to diagnose the issue? 是否知道为什么会这样或如何诊断问题? The JS console isn't showing me any errors.
JS控制台没有显示任何错误。
@Component({
selector: 'slice',
template: `SLICE: {{ obs$ | async }}
})
export class Slice {
obs$: Observable<any>
constructor(private store:Store<any>) {
this.obs$ = this.store.select(s => s.slice);
}
}
I had a similar problem once. 我曾经有过类似的问题。 In my case angular did not render the template when the
async
pipe was used inside a *ngFor
block. 在我的情况下,当在
*ngFor
块内使用async
管道时,angular不会渲染模板。
I was including the minified version of Angular2.beta13 and I solved by including Angular with the beautified JavaScript. 我包含了Angular2.beta13的缩小版,并且通过将Angular与美化的JavaScript包含在一起来解决。
https://stackoverflow.com/a/36458828/2332293 https://stackoverflow.com/a/36458828/2332293
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.