You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
591 B

import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
@Component({
selector: 'app-search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.css']
})
export class SearchComponent implements OnInit {
results;
constructor(
private http: Http
) { }
findCharacter(name){
this.http.get('http://swapi.co/api/people/?search=' + name)
.toPromise()
.then(response => this.results = response.json().results);
}
ngOnInit() {
}
}