source: trip-planner-front/src/app/planner/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 { Component, OnInit } from '@angular/core';
2import { Planner } from '../_models/planner';
3import { PlannerService } from '../_services/planner.service';
4import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
5import { CreateInitialPlannerComponent } from '../create-initial-planner/create-initial-planner.component';
6import { Router } from '@angular/router';
7import { PlannerDto } from '../_models/dto/plannerDto';
8import { FormBuilder, FormGroup, Validators } from '@angular/forms';
9
10
11@Component({
12 selector: 'app-planner',
13 templateUrl: './planner.component.html',
14 styleUrls: ['./planner.component.css']
15})
16export class PlannerComponent implements OnInit {
17
18 planners: Planner[];
19 plannerDto: PlannerDto;
20 editForm: FormGroup;
21
22
23
24 constructor(private plannerService: PlannerService, private dialog: MatDialog, private router: Router,
25 private fb : FormBuilder) {
26 this.planners = [];
27 this.plannerDto = new PlannerDto();
28 this.editForm = fb.group({
29 title: fb.control('initial value', Validators.required)
30 });
31 };
32
33 openDialog(): void {
34 const dialogRef = this.dialog.open(CreateInitialPlannerComponent, {
35 width: '250px',
36 data: {}
37 });
38 }
39
40 ngOnInit(): void {
41 this.plannerService.getAllPlanners().subscribe(
42 data => {
43 this.planners = data;
44 }
45 );
46 }
47
48 onClickEditPlannerGet(id: number){
49 console.log(id);
50 this.plannerService.getPlannerById(id).subscribe(
51 data => {
52 this.router.navigate(['edit/planner/', id]);
53 }
54 );
55
56 }
57
58
59}
Note: See TracBrowser for help on using the repository browser.