I have this code which works as expected:
this.filteredCampaigns = this.allCampaigns.filter((item) => item.status!.includes(filterConditions))
//this.filteredCampaigns is of type Campaign[] | null and allallCampaigns is of type
product.Campaign[]
the.filteredCampaingns is empty, while the allCampaigns stores all data. When I try to concat it, it returns undefined and no compiler errors:
this.filteredCampaigns.concat(this.allCampaigns.filter((item) => item.status!.includes(filterConditions))) //returns undefined
When I instead try push, I get an error
Type 'Campaign[]' has no properties in common with type 'Campaign'.ts(2559)
this.filteredCampaigns.push(this.allCampaigns.filter((item) =>
item.status!.includes(filterConditions))) //returns undefined
How to solve this? I can only declare the value of the array, but I need to add/push more data in to it which does not work.
In the following order:
this.filteredCampaigns = this.allCampaigns.filter((item) => item.description?.toLowerCase().includes(filteredString))
this.filteredCampaigns.concat(this.allCampaigns.filter((item) => item.type?.toLowerCase().includes(filteredString)));
this.filteredCampaignsbefore you call.concat()or.push()?push()?concatdoesn't alter the arrays it's being called on, nor the arguments provided - it returns a shallow copy. Are you storing the result of that call anywhere?