Skip to content

Instantly share code, notes, and snippets.

@kobvel
Last active October 4, 2017 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobvel/b31db426f2c5e9c77cbb35aeeb45d93d to your computer and use it in GitHub Desktop.
Save kobvel/b31db426f2c5e9c77cbb35aeeb45d93d to your computer and use it in GitHub Desktop.
import { OnInit, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs/Rx';
import { ApiService } from '../../shared/api.service';
@Component()
export class ProfileComponent implements OnInit, OnDestroy {
public profileData$: Subscription;
public data;
constructor(private apiService: ApiService) {}
ngOnInit() {
this.profileData$ = this.apiService.getProfileData()
.subscribe(data => this.data = data);
}
ngOnDestroy() {
this.profileData$.unsubscribe();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment