Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <div class="checkbox">
  2. <label>
  3. <input #saveUsername [(ngModel)]="saveUsername.selected" type="checkbox" data-toggle="toggle">Benutername speichern
  4. </label
  5. ></div>
  6.  
  7. import { Component, OnInit } from '@angular/core';
  8. import { Router } from '@angular/router';
  9. import { Variables } from '../../services/variables';
  10.  
  11. @Component({
  12. selector: 'login',
  13. moduleId: module.id,
  14. templateUrl: 'login.component.html',
  15. styleUrls: ['login.component.css']
  16. })
  17.  
  18.  
  19. export class LoginComponent implements OnInit {
  20.  
  21. private saveUsername: boolean = true;
  22. private autoLogin: boolean = true;
  23. constructor(private router: Router, private variables: Variables) { }
  24.  
  25. ngOnInit() {
  26. this.loginValid = false;
  27. // Hole Usernamen aus Local Storage falls gespeichert werden soll
  28. if (window.localStorage.getItem("username") === null) {
  29. this.saveUsername = true;
  30. this.autoLogin = true;
  31. console.log(this.saveUsername, this.autoLogin);
  32. } else {
  33. console.log("init", window.localStorage.getItem("username"));
  34. }
  35. }
  36.  
  37. login(username: string, password: string, saveUsername: boolean, autoLogin: boolean) {
  38. this.variables.setUsername(username);
  39. this.variables.setPassword(password);
  40. this.variables.setIsLoggedIn(true);
  41. console.log(saveUsername, autoLogin);
  42. //this.router.navigate(['dashboard']);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement