We have had a good start for the company module from earlier, when we implemented the "add new company" functionality. So, we can jump in and create and implement the rest of the files to display all companies.
In order to display a list of companies in our application, we create a new component file, called public/src/company/components/company-list.component.ts
:
import { Component, OnInit } from 'angular2/core'; import { Router, RouterLink } from 'angular2/router'; import { CompanyService } from '../company.service'; import { Company } from '../company.model'; @Component({}) export class CompanyListComponent implements OnInit { public companies: Array<Company>; private _router: Router; private _companyService: CompanyService; constructor(companyService: CompanyService, router: Router) { this._router = router; this._companyService = companyService; } ngOnInit() { this._companyService .getAll() .subscribe((companies) => { ...