Guest User

Untitled

a guest
Nov 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import { RockBand } from './services/rock-bands.service';
  3.  
  4. @Component({
  5. selector: 'app-root',
  6. template: `
  7. <h2>List of Rock Bands that rocks!: </h2>
  8. <ul>
  9. <li *ngFor="let rockBand of rockBands">
  10. {{rockBand.id}} - {{rockBand.name}}
  11. </li>
  12. </ul>
  13. `,
  14. styleUrls: ['./app.component.css']
  15. })
  16. export class AppComponent implements OnInit {
  17. rockBands: RockBand[];
  18.  
  19. constructor(private rockBandService: RockBand) {}
  20.  
  21. ngOnInit() {
  22. this.getRockBands();
  23. }
  24.  
  25. getRockBands() {
  26. this.rockBandService.getRockBands()
  27. .subscribe((response) => {
  28. this.rockBands = response;
  29. });
  30. }
  31. }
Add Comment
Please, Sign In to add comment