[英]RXJS in Angular 6 returns only { “_isScalar”: false }
I'm trying RXJS
for the first time. 我是第一次尝试
RXJS
。 Although I'm following the steps I found in a tutorial literally my component isn't getting the sate in the Store
but instead it's getting the object { "_isScalar": false }
. 尽管按照我在教程中发现的步骤进行操作,但实际上我的组件不是在
Store
获得{ "_isScalar": false }
的状态,而是在获取对象{ "_isScalar": false }
。
Here the code: 这里的代码:
Component HTML: 组件HTML:
<div>
{{ selectedProcess }}
</div>
Component TS: 组件TS:
import { Component, OnInit, Input } from '@angular/core';
import { Store, Select } from '@ngxs/store';
import { Observable } from 'rxjs';
import { Process } from '../../../../models/process';
import { ProcessState } from '../../../../state/process.state';
@Component({
selector: 'app-process',
templateUrl: './process.component.html',
styleUrls: ['./process.component.scss']
})
export class OneProcessComponent implements OnInit {
@Select(ProcessState.getProcess) selectedProcess: Observable<Process>;
constructor(private store: Store) { }
ngOnInit() {}
}
PS: I checked the state file and realized the state is updating correctly. PS:我检查了状态文件,发现状态正在正确更新。 Still the receiving component can't get the data but getting the above-mentioned object instead.
接收组件仍然无法获取数据,而是获取上述对象。
Its observable. 其可见。 You cannot just print it like
{{selectedProcess}}
. 您不能只像
{{selectedProcess}}
那样打印它。 You have to use async
pipe which subscribes to observable and prints out the result: 您必须使用
async
管道,该管道订阅可观察的内容并打印出结果:
{{selectedProcess | async}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.