httpコールを行うためにngrx/effectsを使用してangular2アプリケーションを開発しました。私は参考アプリケーションとしてGITを使用しました。応答がhttpから来たら、私はそれを画面に表示することができません。その[オブジェクトオブジェクト]を表示します。ここに私のコードです。ご覧のとおりangle2のアプリケーションで[オブジェクトオブジェクト]を取得する
<div class="container">
<div class="left-container cf">
<mat-tab-group>
<mat-tab label="Configuration">{{jsons}}</mat-tab>
<mat-tab label="Captured Output">
</mat-tab>
</mat-tab-group>
</div>
</div>
Component.ts
export class ExperimentDetailsComponent implements OnInit {
jsons: Observable<any>;
isLoading: Observable<any>;
constructor(
private store: Store<fromStore.State>
) {
this.isLoading = store.select(fromStore.getIsLoading);
this.jsons = store.select(fromStore.getJson);
console.log(this.jsons)
}
ngOnInit() {
this.store.dispatch(new jsonAction.GetJson());
// this.jsons = this.store.select(fromStore.getJson);
}
}
Effects.ts
export class GetJsonEffects {
@Effect() json$ = this.actions$.ofType(Act.GET_JSON)
.map(toPayload)
.withLatestFrom(this.store$)
.mergeMap(([ payload, store ]) => {
return this.http$
.get(`http://localhost:4000/data/`)
.map(data => {
return new Act.GetJsonSuccess({ data: data })
})
.catch((error) => {
return Observable.of(
new Act.GetJsonFailed({ error: error })
);
})
});
constructor(
private actions$: Actions,
private http$: HttpClient,
private store$: Store<fromStore.State>
) {}
}
あなたのコードのどの部分が '[Object Object] 'に関連していますか?それはどこに表示されますか?期待される行動は何ですか? –
jsonオブジェクトを表示したい場合は、 'json'パイプを使うことができます:' {{jsons | json}} ' – n00dl3
返事ありがとうございます。もし私が{{jsons | json}}エラーが発生しています - ERROR TypeError:循環構造をJSONに変換 – naik3