Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

I think that the value you set in the indexes property isn't an array but an object.

I would see several reasons for this:

  • You receive the response instead of the payload from the getIndexes method. In this case, you could use the map operator in this method:

      getIndexes() {
        return this.http.get(...).map(res => res.json());
      }
    
  • The received payload doesn't correspond to an array but some of its properties. In this case, you need to set this property into the indexes property.

If you want to iterate over the properties of an object, you need to implement a custom filter like this:

@Pipe({name: 'keyValues'})
export class KeysPipe implements PipeTransform {
  transform(value, args:string[]) : any {
    let keys = [];
    for (let key in value) {
      keys.push({key: key, value: value[key]);
    }
    return keys;
  }
}

and use it like that:

<div class="div_IndxPartition" *ngFor="#indObj of indexes | keyValues">
  (...)
</div>

See this question:

I think that the value you set in the indexes property isn't an array but an object.

I would see several reasons for this:

  • You receive the response instead of the payload from the getIndexes method. In this case, you could use the map operator in this method:

      getIndexes() {
        return this.http.get(...).map(res => res.json());
      }
    
  • The received payload doesn't correspond to an array but some of its properties. In this case, you need to set this property into the indexes property.

If you want to iterate over the properties of an object, you need to implement a custom filter like this:

@Pipe({name: 'keyValues'})
export class KeysPipe implements PipeTransform {
  transform(value, args:string[]) : any {
    let keys = [];
    for (let key in value) {
      keys.push({key: key, value: value[key]);
    }
    return keys;
  }
}

and use it like that:

<div class="div_IndxPartition" *ngFor="#indObj of indexes | keyValues">
  (...)
</div>

See this question:

I think that the value you set in the indexes property isn't an array but an object.

I would see several reasons for this:

  • You receive the response instead of the payload from the getIndexes method. In this case, you could use the map operator in this method:

      getIndexes() {
        return this.http.get(...).map(res => res.json());
      }
    
  • The received payload doesn't correspond to an array but some of its properties. In this case, you need to set this property into the indexes property.

If you want to iterate over the properties of an object, you need to implement a custom filter like this:

@Pipe({name: 'keyValues'})
export class KeysPipe implements PipeTransform {
  transform(value, args:string[]) : any {
    let keys = [];
    for (let key in value) {
      keys.push({key: key, value: value[key]);
    }
    return keys;
  }
}

and use it like that:

<div class="div_IndxPartition" *ngFor="#indObj of indexes | keyValues">
  (...)
</div>

See this question:

Source Link
Thierry Templier
  • 202.6k
  • 44
  • 407
  • 365

I think that the value you set in the indexes property isn't an array but an object.

I would see several reasons for this:

  • You receive the response instead of the payload from the getIndexes method. In this case, you could use the map operator in this method:

      getIndexes() {
        return this.http.get(...).map(res => res.json());
      }
    
  • The received payload doesn't correspond to an array but some of its properties. In this case, you need to set this property into the indexes property.

If you want to iterate over the properties of an object, you need to implement a custom filter like this:

@Pipe({name: 'keyValues'})
export class KeysPipe implements PipeTransform {
  transform(value, args:string[]) : any {
    let keys = [];
    for (let key in value) {
      keys.push({key: key, value: value[key]);
    }
    return keys;
  }
}

and use it like that:

<div class="div_IndxPartition" *ngFor="#indObj of indexes | keyValues">
  (...)
</div>

See this question: