How to filter json return value using multiple form field value?

Dear Friends,

My doubt is,how to filter the json data using multiple field values my json return is :

i need to filter it with 3 fields : intWardYearID, intWardNo, intDoorNO

i get the form field value for above 3 fields easily as in code:

getBuilding() {
    //alert('wardyr'; --> Ward year
    // like this got all fields here!
    .then(data => { = data;

Please advise



newArray = array.filter(item => property1 && property2 && property3)

But aaron,
I got error in typescript as

[ts] Property ‘filter’ does not exist on type ‘{}’.

my data type is

data:any = {};


Get in the habit of typing your variables. If you do, you will have access to more powerful functions.

please advise how to make this

data: any = {}

type proper. I am new to ionic and angular js

It depends on what datatype this.propertyProvider.getBuilding returns. If it returns an Array, then you could write:

.then((data: Array) => {

Hi AndrW,

When I try to cast it to array got Type script as below:

My return value of that data is json

Can you post this code: this.propertyProvider.getBuilding?


getBuilding() { //Search result for panchayat 
    return new Promise(resolve => {
      this.http.get(this.searchUrl).subscribe(data => {
        alert('from provider'+data);
      }, err => {

my searchurl is :

Don’t do this. It’s the explicit Promise construction antipattern. I don’t know where you are getting your code ideas from, but whichever tutorials you are reading, they are not good.

Then please advise a proper method to do my work sir …

You could try to filter with:

let result = JSON.parse(data).filter(function (entry) {
        return entry.intWardYearID==='someValue' && entry.intWardNo==='someValue && entry.intDoorNO==='someValue'

I recommend you take a step back and read some documentation. The official Angular docs about HttpClient would be a good place to start.

Sir please provide that link which is helpful for me. I have a not mandatory field ‘Subnumber’ which may be given or left blank in search… How to handle that field in this ‘result’ filtration.

please advise

1 Like

Well, if that filter is working, then it’s just a matter of coding from there…

I got that snippet from here:

yes that code works fine. Thanks alot AndreW :star_struck:

1 Like

Hi Anespa, can you share your code to filter using multiple fields? Thanks