Complete the code to import the ActivatedRoute service.
import { [1] } from '@angular/router';
The ActivatedRoute service is imported from @angular/router to access route parameters.
Complete the constructor to inject ActivatedRoute.
constructor(private [1]: ActivatedRoute) {}The common convention is to name the injected ActivatedRoute as route in the constructor.
Fix the error in accessing the route parameter named 'id'.
this.route.params.subscribe(params => {
this.id = params[1];
});Route parameters are accessed as properties of the params object using bracket notation like params['id'].
Complete the code to correctly get the 'userId' parameter from the snapshot.
const userId = this.route[1].params['userId'];
To get a route parameter from the snapshot, use this.route.snapshot.params['userId']. The second blank is empty because params is a property, not a function.
Fill both blanks to subscribe to route params and assign 'productId' to a variable.
this.route[1].subscribe(params => { this.productId = params[[2]]; });
Subscribe to this.route.params observable, then access the 'productId' parameter using params['productId']. The third blank is the string key for the parameter.