Guest User

Untitled

a guest
May 30th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. export class AppComponent {
  2. public isValid:boolean;
  3. constructor(private router:Router){
  4. }
  5. logout(){
  6. localStorage.removeItem('email');
  7. this.router.navigate(['./login']);
  8. this.isValid=true;
  9. }
  10. }
  11.  
  12. export class LoginComponent implements OnInit {
  13. public username:string;
  14. public password:string;
  15. constructor(private router:Router) { }
  16. ngOnInit() {
  17. }
  18. userLogin(form:NgForm){
  19. if(form.value.username==="admin@gmail.com" && form.value.password==="admin")
  20. {
  21. localStorage.setItem('email',form.value.username);
  22. this.router.navigate(['./php']);
  23. this.isValid=false;//not working//
  24. } } }
  25.  
  26. <ul class="nav navbar-nav navbar-right">
  27. <li *ngIf="isValid">
  28. <a [routerLink]="['/login']" >Login</a>
  29. </li>
  30.  
  31. <li *ngIf="!isValid">
  32. <a (click)="logout()">LogOut</a>
  33. </li>
  34.  
  35. </ul>
Add Comment
Please, Sign In to add comment