My goal is to extract queryParams
from a URL and leverage that information to resolve data in the following manner:
data = {
searchValue: null || undefined
};
constructor(private http: HttpClient, private route: ActivatedRoute) {
route.queryParams.subscribe(params => this.data.searchValue = params.search);
}
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<any> {
console.log(this.data);
if (!this.data) {
throwError(console.error());
}
Even though I set the data in the constructor, it continues to log as undefined. I'm uncertain about why it's not functioning properly, and I would greatly appreciate if someone could elaborate on my mistake and provide guidance on how to address the issue.