Iterate through json string in Observable angular js 2

后端 未结 1 1070
北荒
北荒 2021-01-26 10:57

Following is my html code,

                       
                 {{c.name}}
                <         


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-26 11:27

    You could create a custom pipe to return the list of key for each element. Something like that:

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

    and use it like that:

               
      {{key}}: {{c[key]}}
    
    

    0 讨论(0)
提交回复
热议问题