angular - How to get rid of Angular6 typescript error?
问题描述
I'm building an angular 6 project with typescript 3.1.2. I'm calling a restful API that returns a JSON data set with a label name data. I'm getting the below error but the website works perfectly without any console error. Is this a bug or I'm I doing something wrong?
error TS2339: Property 'data' does not exist on type 'AgentData[]'.
Here is my Agent Component subscribing to the service.
This is the error from VS Code Editor:
[ts] Property 'data' does not exist on type 'AgentData[]'
解决方案
您的方法返回类型应该Observable<AgentData>
是Observable<AgentData[]>
推荐阅读
- excel - 如何使用计算字段对数据透视表中的负数求和?
- java - 杰克逊注释转换 BigDecimal 值并将比例设置为 2
- ios - 调整具有 2 个原型单元格的表格视图单元格
- java - Struts 2 ~ 启动套接字的最佳位置?
- flutter - 从未来函数获取数据到文本小部件
- ios - 将角半径应用于 Storyboard 内的特定 UIView 角不适用于所有角
- raku - Perl6 中的 Sub vs Blocks - 又名罗马数字挑战
- directx - 什么是 ID3D12GraphicsCommandList::DiscardResource?
- java - DATE 类型的 MySql 列在 javafx tableview 中显示为一天前
- html - HTML 中的图像和文本一个标签,其中图像调整大小以适合容器