Skip to content

Instantly share code, notes, and snippets.

@ganqqwerty
Last active October 29, 2019 14:19
Show Gist options
  • Save ganqqwerty/66b647c6b5dcfd45d4f23b17c1272715 to your computer and use it in GitHub Desktop.
Save ganqqwerty/66b647c6b5dcfd45d4f23b17c1272715 to your computer and use it in GitHub Desktop.
@Component({
selector: "app-totoro",
template: `
<pre>{{ totoroDetails | json }}</pre>
`
})
export class TotoroComponent implements OnInit, OnDestroy {
totoroDetails: string;
subscription: Subscription<any>;
constructor(private http: HttpClient) {}
ngOnInit() {
subscrition = this.http
.get(
"https://ghibliapi.herokuapp.com/films/58611129-2dbc-4a81-a72f-77ddfc1b1b49"
)
.subscribe(response => (this.totoroDetails = response.description));
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment