source: trip-planner-front/src/app/planner/planner.component.ts@ 6a80231

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

create initial planner and routing with angular

  • Property mode set to 100644
File size: 1.2 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';
7
8
9@Component({
10 selector: 'app-planner',
11 templateUrl: './planner.component.html',
12 styleUrls: ['./planner.component.css']
13})
14export class PlannerComponent implements OnInit {
15
16 planners: Planner[];
17 plannerId: number;
18
19 constructor(private plannerService: PlannerService, public dialog: MatDialog, private router: Router) {
20 this.planners = [];
21 this.plannerId = 1;
22 };
23
24 openDialog(): void {
25 const dialogRef = this.dialog.open(CreateInitialPlannerComponent, {
26 width: '250px',
27 data: {}
28 });
29 }
30
31 ngOnInit(): void {
32 this.plannerService.getAllPlanners().subscribe(
33 data => {
34 this.planners = data;
35 }
36 );
37 }
38
39 onClickEditPlanner(id: number){
40 console.log(id);
41
42
43 this.router.navigate(['edit/planner/', this.plannerId])
44
45 }
46}
Note: See TracBrowser for help on using the repository browser.