source: trip-planner-front/src/app/create-initial-planner/create-initial-planner.component.ts@ ceaed42

Last change on this file since ceaed42 was ceaed42, checked in by Ema <ema_spirova@…>, 3 years ago

add location to planner

  • Property mode set to 100644
File size: 1.6 KB
Line 
1import { ResourceLoader } from '@angular/compiler';
2import { Route } from '@angular/compiler/src/core';
3import { Component, Inject, OnInit } from '@angular/core';
4import { NgForm } from '@angular/forms';
5import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
6import { ActivatedRoute, Params, Router } from '@angular/router';
7import { PlannerDto } from '../_models/dto/plannerDto';
8import { Planner } from '../_models/planner';
9import { PlannerService } from '../_services/planner.service';
10
11@Component({
12 selector: 'app-create-initial-planner',
13 templateUrl: './create-initial-planner.component.html',
14 styleUrls: ['./create-initial-planner.component.css']
15})
16export class CreateInitialPlannerComponent implements OnInit {
17
18 planner: Planner;
19 planners: Planner[];
20 plannerDto: PlannerDto;
21
22 constructor(private dialogRef: MatDialogRef<CreateInitialPlannerComponent>,
23 private plannerService : PlannerService, private router : Router) {
24 this.planner = new Planner;
25 this.planners = [];
26 this.plannerDto = new PlannerDto();
27 }
28
29 ngOnInit(): void {
30 this.planner = new Planner();
31 this.plannerDto = new PlannerDto();
32 }
33
34 onCancelClick(): void {
35 this.dialogRef.close();
36 }
37
38 onFormSubmitPlanner(form: NgForm){
39 console.log(this.planner);
40 this.plannerService.postInitialPlanner(this.planner).subscribe(
41 data=>{
42 console.log(data);
43 this.router.navigate(['planner']);
44 },
45 error => console.log('oops', error)
46 );
47 window.location.reload();
48 }
49
50
51}
Note: See TracBrowser for help on using the repository browser.