Angular-cliプロジェクトでは、このコードを検索フィルタ付きのデータテーブル用に実装しました。私はloadshを使用して、次のリンクにあるチュートリアルを使用しました。ここで http://plnkr.co/edit/grhag1P85teN4ftggkms?p=previewanguar 2 anger2-datatableの検索フィルタクエリ - 'first_name'プロパティがタイプ '{}'に存在しません
パッケージのリンクです:https://github.com/mariuszfoltak/angular2-datatable
私は検索フィルタを追加すると、それはにupdateData機能に私は、このエラーを示しました。 プロパティ 'first_name'は型 '{}'に存在しません。 typescriptやloadshのバージョンなどで問題はありますか?ここで
export class UsersComponent implements OnInit {
public users: any = [];
public filteredData: any;
public filterQuery = "";
public rowsOnPage = 10;
public sortBy = "first_name";
public sortOrder = "asc";
ngOnInit() {
this.authService.getUsersList(userData).subscribe(data => {
var res = data.response;
this.users = this.users;
this.filteredData = res.data;
});
}
public updateData(query:string) {
if(query) {
this.filteredData = _.filter(this.users, (a)=>a.first_name.indexOf(query)>=0);
} else {
this.filteredData = this.users;
}
}
}
がloadshバージョン
"dependencies": {
"angular2-datatable": "^0.6.0",
"lodash": "^4.17.4",
},
"devDependencies": {
"@types/lodash": "^4.14.50",
"typescript": "~2.0.3"
}
使用します。 'a ['first_name']'を使ってみてください。 –