Skip to content

Instantly share code, notes, and snippets.

@elvinmeza
Created November 21, 2017 16:38
Show Gist options
  • Save elvinmeza/fca6a6de2bbadb682cc29429829e8e64 to your computer and use it in GitHub Desktop.
Save elvinmeza/fca6a6de2bbadb682cc29429829e8e64 to your computer and use it in GitHub Desktop.
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