Last change
on this file since 0e4e3d1 was 8423429, checked in by AngelNasev <angel.nasev@…>, 17 months ago |
Add backend and frontend projects
|
-
Property mode
set to
100644
|
File size:
817 bytes
|
Line | |
---|
1 | import { Injectable } from '@angular/core';
|
---|
2 | import {HttpClient, HttpParams} from "@angular/common/http";
|
---|
3 | import {Router} from "@angular/router";
|
---|
4 | import {QuestionInterface} from "./QuestionInterface";
|
---|
5 | import {AnswerInterface} from "./AnswerInterface";
|
---|
6 |
|
---|
7 | @Injectable({
|
---|
8 | providedIn: 'root'
|
---|
9 | })
|
---|
10 | export class AddAnswerService {
|
---|
11 |
|
---|
12 | url = "http://localhost:8080/api/answers/add"
|
---|
13 | constructor(private http: HttpClient, private router: Router) {
|
---|
14 | }
|
---|
15 |
|
---|
16 | add(content: string, username: string, questionId: number) {
|
---|
17 | const params = new HttpParams()
|
---|
18 | .append("content",content)
|
---|
19 | .append("username",username)
|
---|
20 | .append("questionId",questionId)
|
---|
21 | this.http.get<AnswerInterface>(this.url, {params:params})
|
---|
22 | .subscribe(resp => {
|
---|
23 | this.router.navigate(['/question-details/'+questionId]);
|
---|
24 | })
|
---|
25 | }
|
---|
26 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.