source: Sources/frontend/src/app/register.service.ts@ 8423429

Last change on this file since 8423429 was 8423429, checked in by AngelNasev <angel.nasev@…>, 15 months ago

Add backend and frontend projects

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import { Injectable } from '@angular/core';
2import {ActiveUserInterface} from "./ActiveUserInterface";
3import {HttpClient, HttpParams} from "@angular/common/http";
4import {Router} from "@angular/router";
5import {LoginService} from "./login.service";
6
7@Injectable({
8 providedIn: 'root'
9})
10export class RegisterService {
11
12 url = "http://localhost:8080/api/register"
13 activeUser: ActiveUserInterface | undefined;
14 constructor(private http:HttpClient,
15 private router: Router,
16 private loginService: LoginService) {
17 }
18 registerUser(name:string, lastName:string, email:string, username:string, password:string, userType:string, index:string){
19 const params = new HttpParams()
20 .append("name",name)
21 .append("lastName",lastName)
22 .append("email",email)
23 .append("username",username)
24 .append("password",password)
25 .append("userType",userType)
26 .append("index",index);
27 this.http.get<ActiveUserInterface>(this.url,{params:params})
28 .subscribe(resp =>{
29 this.activeUser = resp;
30 this.loginService.activeUser = this.activeUser;
31 this.router.navigate(['/allCourses']);
32 })
33 }
34}
Note: See TracBrowser for help on using the repository browser.