I'm trying to access the array countriesList which I receive as a response in my Angular 4 component. The response contain details about countries like name, capital, population etc.
how do I get the length of array countriesList in my component.ts?
import { Component, OnInit } from '@angular/core';
import { Chart, Highcharts } from 'angular-highcharts';
import { CountriesserviceService } from '../countriesservice.service';
@Component({
selector: 'app-graph1',
templateUrl: './graph1.component.html',
styleUrls: ['./graph1.component.css'],
providers: [CountriesserviceService]
})
export class Graph1Component implements OnInit {
countriesList: any[];
constructor(private countriesService: CountriesserviceService) { }
ngOnInit() {
this.countriesService.getCountries().subscribe(countriesList =>
this.countriesList = countriesList.json() );
console.log(this.countriesList);
}
}