Created
November 21, 2017 16:38
-
-
Save elvinmeza/fca6a6de2bbadb682cc29429829e8e64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { RockBand } from './services/rock-bands.service'; | |
@Component({ | |
selector: 'app-root', | |
template: ` | |
<h2>List of Rock Bands that rocks!: </h2> | |
<ul> | |
<li *ngFor="let rockBand of rockBands"> | |
{{rockBand.id}} - {{rockBand.name}} | |
</li> | |
</ul> | |
`, | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent implements OnInit { | |
rockBands: RockBand[]; | |
constructor(private rockBandService: RockBand) {} | |
ngOnInit() { | |
this.getRockBands(); | |
} | |
getRockBands() { | |
this.rockBandService.getRockBands() | |
.subscribe((response) => { | |
this.rockBands = response; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment