Added routing after login/registering

This commit is contained in:
piratefinn 2017-05-10 16:26:57 +01:00
parent b6ab962f36
commit b888fb0193
2 changed files with 10 additions and 4 deletions

View file

@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { Http, Response } from '@angular/http';
import { ApiService } from '../providers/api-service';
import {Router } from '@angular/router';
import 'rxjs/add/operator/map';
@Component({
@ -15,6 +16,7 @@ export class LoginComponent {
constructor(
private http: Http,
private formBuilder: FormBuilder,
private router: Router,
private api: ApiService
) {
this.api.getAgeRanges()
@ -33,11 +35,12 @@ export class LoginComponent {
onSubmit() {
console.log(this.signin.value);
this.peopleService
this.api
.register(this.signin.value)
.subscribe(
result => {
console.log( logged in! );
console.log('logged in!');
this.router.navigate(['/dashboard'])
},
error => {
console.log( error._body );

View file

@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { Http, Response } from '@angular/http';
import { ApiService } from '../providers/api-service';
import {Router } from '@angular/router';
import 'rxjs/add/operator/map';
@Component({
@ -15,6 +16,7 @@ export class RegisterComponent {
constructor(
private http: Http,
private formBuilder: FormBuilder,
private router: Router,
private api: ApiService
) {
this.api.getAgeRanges()
@ -38,11 +40,12 @@ export class RegisterComponent {
onSubmit() {
console.log(this.signup.value);
this.peopleService
this.api
.register(this.signup.value)
.subscribe(
result => {
console.log( registered! );
console.log('registered!');
this.router.navigate(['/dashboard']);
},
error => {
console.log( error._body );