Skip to content

Instantly share code, notes, and snippets.

@manivelarjunan
Created December 2, 2018 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save manivelarjunan/ee10651521cf556eec7353e914b21ce4 to your computer and use it in GitHub Desktop.
Save manivelarjunan/ee10651521cf556eec7353e914b21ce4 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { UserAsyncService } from './user-async.service';
import { Observable } from 'rxjs';
@Component({
selector: 'app-user-async',
templateUrl: './user-async.component.html',
styleUrls: ['./user-async.component.scss'],
providers: [UserAsyncService]
})
export class UserAsyncComponent implements OnInit {
isLoggedIn = false;
user: { name: string };
userDetail;
systemError = false;
systemErrorMessage = '';
constructor(private userAsyncService: UserAsyncService) {}
ngOnInit() {
this.userAsyncService = this.userAsyncService.getUserDetails().subscribe(
(respone: string) => {
this.userDetail = respone;
this.isLoggedIn = true;
},
(error: string) => {
this.systemError = true;
this.systemErrorMessage = error;
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment