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