angular2-filtering

Search for a string in all properties of an object in Angular 2

霸气de小男生 提交于 2020-12-25 08:51:13
问题 How to search for a string in all properties of an object in Angular 2 with TS. I have an array of customers rendered in a table with a search box, if the user types a value I want to search for all properties values to push a customer that matches the value typed. export var CUSTOMER: Client[] = [ { id: 1, name: 'John', phone: '888-888-888'}, { id: 2, name: 'Nick', phone: '555-888-888'}, { id: 3, name: 'Mike', phone: '666-888-888'}, ]; The Filter Pipe import {Pipe, PipeTransform, Injectable}

Search for a string in all properties of an object in Angular 2

徘徊边缘 提交于 2020-12-25 08:48:19
问题 How to search for a string in all properties of an object in Angular 2 with TS. I have an array of customers rendered in a table with a search box, if the user types a value I want to search for all properties values to push a customer that matches the value typed. export var CUSTOMER: Client[] = [ { id: 1, name: 'John', phone: '888-888-888'}, { id: 2, name: 'Nick', phone: '555-888-888'}, { id: 3, name: 'Mike', phone: '666-888-888'}, ]; The Filter Pipe import {Pipe, PipeTransform, Injectable}

Typescript: Cannot read property 'toLowerCase' of undefined

梦想与她 提交于 2020-08-11 08:44:12
问题 I am getting this error on line: return filter ? value.filter(element => element.type.toLowerCase().indexOf(filter.toString().toLowerCase()) != -1) : value; when element.type is empty string (filtering empty column). How to fix this? 回答1: As the message states: element.type is undefined . Add a check on that in your filter call. Something like this, what you put depends on what you are expecting back and I can only guess at that. return filter ? value.filter(element => element.type && element

Angular 2 search filter works for one property but not for all properties of an array

核能气质少年 提交于 2020-01-17 06:52:33
问题 In Angular 1, there is filter attribute along with ng-repeat as mentioned here. But in Angular 2 there is new functionality named "pipe" . I have used pipes already but still I can't search through all properties like in the Angular 1 version. However it is working fine for any 1 property, but for whole array, it's not working. I got following error when i search something. ERROR TypeError: Cannot read property 'includes' of null at http://localhost:8100/build/main.js:118751:76 at Array.some

Angular4 search filter functionality on Entire table

梦想与她 提交于 2019-12-13 04:33:32
问题 Here i Implemented small search filter on a table But My Requirement is its should search whole the table not within the page? search <label> Search FRom Table:</label> <input (change)="someval($event.target.value)"> someval(value){ let data=JSON.stringify(value); console.log(data.length); this.auction.find(e=>e.uniqueid=data); this.GetDashBoardData(); } GetDashBoardData(){ var somedata= this.globalService.getBasicInfoData(); this.auctionRequest = { "loginId": this.userdata.LoginID }; return