Skip to content

Instantly share code, notes, and snippets.

@manivelarjunan
Created December 2, 2018 22:34
Show Gist options
  • Save manivelarjunan/f1b4a076bf22a0cc256ad5b48d49df5a to your computer and use it in GitHub Desktop.
Save manivelarjunan/f1b4a076bf22a0cc256ad5b48d49df5a to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { UserService } from './user.service';
@Component({
selector: 'app-user',
templateUrl: './user.component.html',
styleUrls: ['./user.component.scss'],
providers: [UserService]
})
export class UserComponent implements OnInit {
user: { name: string };
isUserLoggedIn = false;
userDetail;
constructor(private userService: UserService) {}
ngOnInit() {
this.userDetail = this.userService.getUser();
if (this.userDetail) {
this.user = this.userDetail;
this.isUserLoggedIn = true;
} else {
this.isUserLoggedIn = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment