I am making an application in Angular. I Have a Json file. How get all 'name' values in the array? Let's say that at the output I could get something like:
['Sony', 'Apple', 'Sony']
Json:
[
{
"Data": [
{
"name": "Sony",
"color": "black"
}
]
},
{
"Data": [
{
"name": "Apple",
"color": "white"
}
]
},
{
"Data": [
{
"name": "Sony",
"color": "red"
}
]
}
]
app.component:
import { Component, OnInit } from '@angular/core';
import resData from '../assets/result.json';
@Component({
selector: 'app-root',
templateUrl: './app.component.pug',
styleUrls: ['./app.component.styl']
})
export class AppComponent {
tasks: any = resData;
console.log(this.tasks); //While displaying just array
}