import {Component, OnInit} from "@angular/core"; import {ActivatedRoute, Router} from "@angular/router"; import {LoginService} from "../services/login-service/login-service"; @Component({ moduleId: module.id, templateUrl: './signup.component.html', styleUrls: ['./login.component.css'] }) export class SignupComponent implements OnInit { showErrorLabel = false; loading = false; returnUrl: string; constructor(private route: ActivatedRoute, private router: Router, private loginService: LoginService) { } ngOnInit() { // reset login status this.loginService.logout(); // redirect on success this.returnUrl = '/cc-overview' } login(username: string, password: string, secret: string) { if (username.length > 0 && password.length > 0 && secret.length > 0) { this.loading = true; this.loginService.signUp(username, password, secret) .subscribe( data => { console.log(data) //this.router.navigate([this.returnUrl]); }, error => { this.showErrorLabel = true; setTimeout(() => { this.showErrorLabel = false; }, 4000); this.loading = false; }); } } }