display films in list

master
Matt Huntington 9 years ago
parent f0a375290f
commit 84b66a3600

@ -1 +1,6 @@
<h2>List of Star Wars Films</h2>
<ul>
<li *ngFor="let film of films">
{{film.title}}
</li>
</ul>

@ -9,13 +9,14 @@ import 'rxjs/add/operator/toPromise';
styleUrls: ['./films.component.css']
})
export class FilmsComponent implements OnInit {
films;
constructor(private http: Http) { }
ngOnInit() {
this.http.get('http://swapi.co/api/films/')
.toPromise()
.then(response => console.log(response.json().results));
.then(response => this.films = response.json().results);
}
}

Loading…
Cancel
Save