Last change
on this file was 8423429, checked in by AngelNasev <angel.nasev@…>, 17 months ago |
Add backend and frontend projects
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | import {Component} from '@angular/core';
|
---|
2 |
|
---|
3 | import {ActiveUserInterface} from "../ActiveUserInterface";
|
---|
4 | import {LoginService} from "../login.service";
|
---|
5 | import {ActivatedRoute, Router} from "@angular/router";
|
---|
6 | import {AddAnswerService} from "../add-answer.service";
|
---|
7 |
|
---|
8 | @Component({
|
---|
9 | selector: 'app-add-answer',
|
---|
10 | templateUrl: './add-answer.component.html',
|
---|
11 | styleUrls: ['./add-answer.component.css']
|
---|
12 | })
|
---|
13 | export class AddAnswerComponent {
|
---|
14 | content: string | undefined;
|
---|
15 | questionId: number | undefined;
|
---|
16 | activeUser: ActiveUserInterface | undefined;
|
---|
17 |
|
---|
18 | constructor(private addAnswerService: AddAnswerService,
|
---|
19 | private loginService: LoginService,
|
---|
20 | private route: ActivatedRoute,
|
---|
21 | private router: Router) {
|
---|
22 | }
|
---|
23 |
|
---|
24 | ngOnInit(): void {
|
---|
25 | this.questionId = Number(this.route.snapshot.paramMap.get('id'));
|
---|
26 | this.activeUser = this.loginService.activeUser;
|
---|
27 | if (!this.activeUser) {
|
---|
28 | this.router.navigate(['/'])
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | submit() {
|
---|
33 | this.addAnswerService.add(this.content!!, this.activeUser!!.username, this.questionId!!)
|
---|
34 | }
|
---|
35 |
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.