SHARE
TWEET

Untitled

a guest Oct 10th, 2016 29 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component, OnInit, Input } from '@angular/core';
  2. import { Router } from '@angular/router';
  3. import { CookieService } from "angular2-cookie/services/cookies.service";
  4. import {LoginService} from "./login.service";
  5.  
  6. @Component({
  7.     moduleId: module.id,
  8.     selector: 'my-login',
  9.     templateUrl: 'login.component.html',
  10.     styleUrls: [ 'login.component.css' ]
  11. })
  12. export class LoginComponent implements OnInit {
  13.     private credentials: Object;
  14.     private submitted:Boolean = false;
  15.  
  16.     constructor(private router: Router,
  17.                 private loginService:LoginService,
  18.                 private cookieService:CookieService) {
  19.         this.credentials = {};
  20.     }
  21.  
  22.     ngOnInit(): void {
  23.         let cookie = this.cookieService.get('token');
  24.         if(cookie) {
  25.             this.router.navigate(['/dashboard']);
  26.         }
  27.     }
  28.  
  29.     onSubmit() {
  30.         this.submitted = true;
  31.         this.loginService.login(this.credentials);
  32.         return false;
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top