Last active
October 29, 2019 14:19
-
-
Save ganqqwerty/66b647c6b5dcfd45d4f23b17c1272715 to your computer and use it in GitHub Desktop.
This file contains 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
@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