I am new on Angular2. I have use \"ngFor\" to iterate over array of objects and show them as matrix having 3 columns f
If your data are contained within an array of objects. You could use a custom pipe to iterate over object keys:
@Pipe({name: 'keys'})
export class KeysPipe implements PipeTransform {
transform(value, args:string[]) : any {
if (!value) {
return value;
}
let keys = [];
for (let key in value) {
keys.push({key: key, value: value[key]);
}
return keys;
}
}
Here is the way to use it:
{{keyValues.key}} = {{keyValues.key}}
The structure of data used are the following:
this.data = [
{ prop1: 'val1 a', prop2: 'val2 a', ... }
{ prop1: 'val1 b', prop2: 'val2 b', ... }
{ prop1: 'val1 c', prop2: 'val2 c', ... }
(...)
];