如何在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.
了解更多: