Added routing after login/registering
This commit is contained in:
parent
b6ab962f36
commit
b888fb0193
2 changed files with 10 additions and 4 deletions
|
@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
||||||
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
|
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
|
||||||
import { Http, Response } from '@angular/http';
|
import { Http, Response } from '@angular/http';
|
||||||
import { ApiService } from '../providers/api-service';
|
import { ApiService } from '../providers/api-service';
|
||||||
|
import {Router } from '@angular/router';
|
||||||
import 'rxjs/add/operator/map';
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -15,6 +16,7 @@ export class LoginComponent {
|
||||||
constructor(
|
constructor(
|
||||||
private http: Http,
|
private http: Http,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
|
private router: Router,
|
||||||
private api: ApiService
|
private api: ApiService
|
||||||
) {
|
) {
|
||||||
this.api.getAgeRanges()
|
this.api.getAgeRanges()
|
||||||
|
@ -33,11 +35,12 @@ export class LoginComponent {
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
console.log(this.signin.value);
|
console.log(this.signin.value);
|
||||||
|
|
||||||
this.peopleService
|
this.api
|
||||||
.register(this.signin.value)
|
.register(this.signin.value)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
result => {
|
result => {
|
||||||
console.log( logged in! );
|
console.log('logged in!');
|
||||||
|
this.router.navigate(['/dashboard'])
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
console.log( error._body );
|
console.log( error._body );
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
||||||
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
|
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
|
||||||
import { Http, Response } from '@angular/http';
|
import { Http, Response } from '@angular/http';
|
||||||
import { ApiService } from '../providers/api-service';
|
import { ApiService } from '../providers/api-service';
|
||||||
|
import {Router } from '@angular/router';
|
||||||
import 'rxjs/add/operator/map';
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -15,6 +16,7 @@ export class RegisterComponent {
|
||||||
constructor(
|
constructor(
|
||||||
private http: Http,
|
private http: Http,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
|
private router: Router,
|
||||||
private api: ApiService
|
private api: ApiService
|
||||||
) {
|
) {
|
||||||
this.api.getAgeRanges()
|
this.api.getAgeRanges()
|
||||||
|
@ -38,11 +40,12 @@ export class RegisterComponent {
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
console.log(this.signup.value);
|
console.log(this.signup.value);
|
||||||
|
|
||||||
this.peopleService
|
this.api
|
||||||
.register(this.signup.value)
|
.register(this.signup.value)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
result => {
|
result => {
|
||||||
console.log( registered! );
|
console.log('registered!');
|
||||||
|
this.router.navigate(['/dashboard']);
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
console.log( error._body );
|
console.log( error._body );
|
||||||
|
|
Reference in a new issue