Guest User

Untitled

a guest
Oct 24th, 2017
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. import { Component, OnInit, Output, EventEmitter } from '@angular/core';
  2. import { DataService } from '../data.service';
  3. import { FormGroup, FormControl, Validators } from '@angular/forms';
  4.  
  5. @Component({
  6. selector: 'app-login',
  7. templateUrl: './login.component.html',
  8. styleUrls: ['./login.component.css']
  9. })
  10. export class LoginComponent implements OnInit {
  11.  
  12. dataService: DataService;
  13.  
  14. myForm: FormGroup;
  15. myPassword = new FormControl();
  16.  
  17. userName = "";
  18. password = "";
  19.  
  20. constructor(dataService:DataService) {
  21. console.log('Login Component Created');
  22. this.dataService=dataService;
  23. this.userName=this.dataService.getName();
  24.  
  25. this.myForm = new FormGroup(
  26. {
  27. myUserName: new FormControl('', [Validators.required]),
  28. myPassword: this.myPassword
  29. }
  30. )
  31. }
  32.  
  33. @Output() loggedin = new EventEmitter<boolean>();
  34.  
  35. ngOnInit() {
  36.  
  37. }
  38.  
  39. reactiveLogin(){
  40. console.log(JSON.stringify(this.myForm.value));
  41. }
  42.  
  43. // login() {
  44. // // if (this.userName == 'Sikim' && this.password ==
  45. // // '12345') {
  46. // // alert("Success");
  47. // // }
  48. // // else {
  49. // // alert("Failed");
  50. // // }
  51. // // this.dataService.setName(this.userName);
  52. // // this.loggedin.emit(true);
  53. // alert("login called");
  54. // }
  55.  
  56. login(values:any){
  57. console.log(JSON.stringify(values));
  58.  
  59. }
  60.  
  61. }
Add Comment
Please, Sign In to add comment