Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit, Output, EventEmitter } from '@angular/core';
- import { DataService } from '../data.service';
- import { FormGroup, FormControl, Validators } from '@angular/forms';
- @Component({
- selector: 'app-login',
- templateUrl: './login.component.html',
- styleUrls: ['./login.component.css']
- })
- export class LoginComponent implements OnInit {
- dataService: DataService;
- myForm: FormGroup;
- myPassword = new FormControl();
- userName = "";
- password = "";
- constructor(dataService:DataService) {
- console.log('Login Component Created');
- this.dataService=dataService;
- this.userName=this.dataService.getName();
- this.myForm = new FormGroup(
- {
- myUserName: new FormControl('', [Validators.required]),
- myPassword: this.myPassword
- }
- )
- }
- @Output() loggedin = new EventEmitter<boolean>();
- ngOnInit() {
- }
- reactiveLogin(){
- console.log(JSON.stringify(this.myForm.value));
- }
- // login() {
- // // if (this.userName == 'Sikim' && this.password ==
- // // '12345') {
- // // alert("Success");
- // // }
- // // else {
- // // alert("Failed");
- // // }
- // // this.dataService.setName(this.userName);
- // // this.loggedin.emit(true);
- // alert("login called");
- // }
- login(values:any){
- console.log(JSON.stringify(values));
- }
- }
Add Comment
Please, Sign In to add comment