how to navigate and set values checked in dropdown in angular

I have two components namely ComponentA and ComponentB. In componentB, there is a link which when clicked should navigate to ComponentA and send data to ComponentA. The values in the data should be set to the dropdown in ComponentA.

The code in ComponentB

  this.router.navigate(['/component-a], {
    queryParams: {
      _series: obj.name1,
      _accyName: this.name2,
      _accyNum: this.name3
    }
  });

The Code in Component A html

<ss-multiselect-dropdown name="modelYear" id="modelYear" [(ngModel)]="this.modelYear" [texts]="selectTextSettings"
                    [settings]="multiSelectSettings" [options]="modelYearOptions"></ss-multiselect-dropdown>

The Code in Component A component.ts (in ngOnInit)

this.modelYear.push(this.dataFromComponentB.modelYear) 

I could able to navigate and get the values from ComponentB but it is not possible to set it the dropdowns in ComponentA. How to achieve this.

12 thoughts on “how to navigate and set values checked in dropdown in angular”

Leave a Comment