You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sup_File/src/app/signup/signup.component.ts

29 lines
820 B
TypeScript

import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Router } from "@angular/router";
import { Observable } from 'rxjs/Observable';
import { tap, catchError } from 'rxjs/operators';
import { of } from 'rxjs/observable/of';
@Component({
selector: 'app-signup',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.css']
})
export class SignupComponent implements OnInit {
signupData = { username:'', password:'' };
message = '';
constructor(private http: HttpClient, private router: Router) { }
signup() {
this.http.post('/api/signup',this.signupData).subscribe(resp => {
// console.log(resp);
this.router.navigate(['login']);
}, err => {
this.message = err.error.msg;
});
}
ngOnInit() {
}
}