Complete the code to navigate with query parameters in Angular.
this.router.navigate(['/search'], { queryParams: [1] });
Query parameters must be passed as an object inside queryParams.
Complete the code to read query parameters using Angular's ActivatedRoute.
this.route.queryParams.subscribe(params => { this.searchTerm = params[1]; });You access query parameters as properties of the params object using dot notation.
Fix the error in the code to navigate with a fragment in Angular.
this.router.navigate(['/details'], { [1]: 'section2' });
The correct property to set a URL fragment is fragment.
Fill both blanks to read query parameters and fragment from ActivatedRoute.
this.route.queryParams.subscribe(params => { this.id = params[1]; });
this.route.[2].subscribe(fragment => { this.section = fragment; });Query parameters are accessed with params.id and fragments with route.fragment.
Fill all three blanks to navigate with query parameters and a fragment.
this.router.navigate([[1]], { queryParams: [2], [3]: 'top' });
The first argument is the route array, queryParams is an object, and fragment is set with the 'fragment' property.
