Currently in my Angular-cli project, I have implemented the following code for a data table with a search filter. The tutorial referenced in the link below was used, leveraging loadsh. http://plnkr.co/edit/grhag1P85teN4ftggkms?p=preview
You can find the package link here: https://github.com/mariuszfoltak/angular2-datatable
While attempting to add a search filter, an error occurred in the updateData function: Property 'first_name' does not exist on type '{}'. Could this issue be related to TypeScript, lodash version, or something else?
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;
}
}
}
Below is the snippet from my package.json file showcasing the lodash version:
"dependencies": {
"angular2-datatable": "^0.6.0",
"lodash": "^4.17.4",
},
"devDependencies": {
"@types/lodash": "^4.14.50",
"typescript": "~2.0.3"
}