1
I have a simple input that serves as a search component, with the Submit function
onSubmit() {
this.submitted = true;
if (!this.searchForm.valid) {
this.submitted = false;
} else {
this.router.navigate(['searchResult/'], {queryParams: {searchText: this.searchForm.get('searchText').value}});
}
}
After this, it goes to the results page, which presents the correct results. But on this page I have the same component, which when doing the search again, changes the value of my URL. However, the search is not performed again.
I believe ngOnInit has already been started, and I would need another way to do "ngOnInit Reload" how to do that? I did some research on Ngonchange but I believe it’s not what I need at the moment.
ngOnInit() {
this.searchTextResult = this.route.snapshot.queryParamMap.get('searchText');
this.getHerosResultByName();
}
It didn’t work my case. I think because ngOnInit is only fired once. But I wasn’t aware of Subject behavior, I’ll give a study
– paulotarcio