source: Sources/frontend/src/app/add-answer/add-answer.component.ts@ 0e4e3d1

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

Add backend and frontend projects

  • Property mode set to 100644
File size: 1.0 KB
Line 
1import {Component} from '@angular/core';
2
3import {ActiveUserInterface} from "../ActiveUserInterface";
4import {LoginService} from "../login.service";
5import {ActivatedRoute, Router} from "@angular/router";
6import {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})
13export 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.