export class ComponentA {
// We need access to the Angular router object to navigate programatically
constructor(private router: Router){}
navigateWithArray(): void {
// Create our query parameters object
const queryParams: any = {};
// Create our array of values we want to pass as a query parameter
const arrayOfValues = ['a','b','c','d'];
// Add the array of values to the query parameter as a JSON string
queryParams.myArray = JSON.stringify(arrayOfVAlues);
// Create our 'NaviationExtras' object which is expected by the Angular Router
const navigationExtras: NavigationExtras = {
queryParams
};
// Navigate to component B
this.router.navigate(['/componentB'], navigationExtras);
}
}