I am trying to print JSON array in HTML using ngFor
TS :
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-ng-for',
templateUrl: './ng-for.component.html',
styleUrls: ['./ng-for.component.scss']
})
export class NgForComponent implements OnInit {
public colors = ["red","blue","green","black","yellow", "pink"]
public count = [1,2,3,4,5, 6]
public item = [
{"one" : 1},
{"two" : 2}
]
constructor() { }
ngOnInit() {
}
}
HTML :
<h1> NG For </h1>
<div *ngFor="let color of colors">
<p>{{color}}</p>
</div>
<div *ngFor="let c of count">
<p>{{c}}</p>
</div>
<div *ngFor="let val of item ">
<p>{{val | json}}</p>
</div>
Here is the output :
But I want to pring Key and Value seperately like this :
KEY : one, Value : 1
KEY : two, Value : 2
What changes should I do?