[英]error TS: 2339 Property “Project” does not exist on type { }
I am using crossfilter js library in my Angular 2 + project, As per documentation of crossfilter, Crossfilter API accepts array of javascript objects. 我在Angular 2 +项目中使用crossfilter js库,根据crossfilter的文档,Crossfilter API接受javascript对象数组。 Using a service I am getting data from mongo db, using observable I am getting data in form of array of Object.
使用服务,我从mongo db获取数据,使用可观察的我以Object数组的形式获取数据。
below is service call in my component 下面是我组件中的服务呼叫
this._getdataservice.getData().subscribe(
function (posts) {
console.log(posts);
var ndx = crossfilter(posts);
var projectDim = ndx.dimension(function(d) { return d.Project });
}
)
I am Getting error as shown in below screen shot 我遇到如下屏幕截图所示的错误
If I print post object in console it is giving array of object 如果我在控制台中打印发布对象,则给出对象数组
Code written in service 服务中编写的代码
getData(): Observable<any> {
return this.http.get<any>(this.url);
}
code written in component in which service is injected 在注入服务的组件中编写的代码
constructor(private _getdataservice: DataServiceService) { }
ngOnInit() {
this._getdataservice.getData().subscribe(function(posts){
console.log(posts);
var ndx = crossfilter(posts);
var projectDim = ndx.dimension(function(d) {return d.Project});
})
}
Please help me to understand where I am doing wrong? 请帮助我了解我在哪里做错了?
将d
的类型更改为any
var projectDim = ndx.dimension(function(d : any) { return d.Project};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.