如何在Angular2/Typescript中调试Observable值? [英] How to debug Observable values in Angular2 / Typescript?

查看:100
本文介绍了如何在Angular2/Typescript中调试Observable值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了有关angular 2的教程,并且具有搜索功能,可以异步呈现英雄列表.

I have followed the tutorial for angular 2 and have a search functionality that renders a list of heroes asynchronously.

<div *ngFor="let hero of heroes | async">
    {{hero.name}}
</div>

在组件中,我有一些可观察到的英雄:

In the component I have observable heroes:

heroes: Observable<Hero[]>;

现在,我在应用程序中实现了类似的功能,因为我什么也看不到,也没有看到任何错误.我在Chrome中打开了调试器,并尝试检查英雄的价值,但这当然只是一些可观察的包装器.

Now I have implemented similar functionality in my application by I don't see anything and I don't see any errors either. I opened the debugger in Chrome and tried to check the value of heroes, but it's just some Observable wrapper of course.

是否有任何方法可以在调试器中查看当前/最后一个值或某些值,或者是否可以使用其他方法来调试此类问题?

Is there any way to see the current/last or some value in the debugger or maybe there is some other technique to debug such issues?

推荐答案

有关此主题的文章很多,但最容易使用

There're several article on this topic but most easily use do() operator to see what's going on in your operator chains.

了解更多:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆