Ignore:
Timestamp:
11/04/21 23:10:39 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
ceaed42
Parents:
6a80231
Message:

edit planner form with angular

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/src/app/planner/planner.component.ts

    r6a80231 r6c1585f  
    55import { CreateInitialPlannerComponent } from '../create-initial-planner/create-initial-planner.component';
    66import { Router } from '@angular/router';
     7import { PlannerDto } from '../_models/dto/plannerDto';
     8import { FormBuilder, FormGroup, Validators } from '@angular/forms';
    79
    810
     
    1517
    1618  planners: Planner[];
    17   plannerId: number;
     19  plannerDto: PlannerDto;
     20  editForm: FormGroup;
    1821
    19   constructor(private plannerService: PlannerService, public dialog: MatDialog, private router: Router) {
     22
     23
     24  constructor(private plannerService: PlannerService, public dialog: MatDialog, private router: Router,
     25    private fb : FormBuilder) {
    2026    this.planners = [];
    21     this.plannerId = 1;
     27    this.plannerDto = new PlannerDto();
     28    this.editForm = fb.group({
     29      title: fb.control('initial value', Validators.required)
     30  });
    2231  };
    2332 
     
    3746  }
    3847 
    39   onClickEditPlanner(id: number){
     48  onClickEditPlannerGet(id: number){
    4049    console.log(id);
    41    
    42          
    43           this.router.navigate(['edit/planner/', this.plannerId])
     50        this.plannerService.getPlannerById(id).subscribe(
     51            data => {
     52             
     53              this.router.navigate(['edit/planner/', id])
     54            }
     55     );
    4456   
    4557  }
     58
     59 
    4660}
Note: See TracChangeset for help on using the changeset viewer.