Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays

后端 未结 18 1180
逝去的感伤
逝去的感伤 2020-11-29 05:50

I looked at similar questions, but none of them helped me. I am going to receive an object like the following:

[
  {
    \"id\": 1,
    \"name\": \"Safa\",
          


        
18条回答
  •  一整个雨季
    2020-11-29 06:15

    My solution is create a Pipe for return the values array or propierties object

    import { Pipe, PipeTransform } from '@angular/core';
    
    @Pipe({
      name: 'valueArray',
    })
    export class ValueArrayPipe implements PipeTransform {
    
      // El parametro object representa, los valores de las propiedades o indice
      transform(objects : any = []) {
        return Object.values(objects);
      }
    }
    

    The template Implement

     
    

提交回复
热议问题