mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
from @art-lowel: update onSelectChange to work with ngModel
Because we're working with ngModel, we're no longer getting a generic JS event in the onSelectChange, but simply the id of the selected option. I use that Id to find the option in the allOptions array that matches, and then use the data inside that matching option to navigate to the correct page.
This commit is contained in:
@@ -69,17 +69,9 @@ export class ComcolPageBrowseByComponent implements OnInit {
|
||||
map((urlSegments: UrlSegment[]) => urlSegments[urlSegments.length - 1].path)
|
||||
);
|
||||
}
|
||||
onSelectChange(target) {
|
||||
const optionIndex = target.selectedIndex;
|
||||
const selectedOptionElement = target.options[optionIndex];
|
||||
const paramsAttribute = selectedOptionElement.getAttribute('data-params');
|
||||
console.log('change value ' + target.value + ' paramsAttribute ' + paramsAttribute);
|
||||
if (paramsAttribute) {
|
||||
/* console.log('Yes paramsAttribute ' + paramsAttribute);*/
|
||||
this.router.navigate([target.value], { queryParams: { scope: paramsAttribute } });
|
||||
} else {
|
||||
/* console.log('No paramsAttribute ');*/
|
||||
this.router.navigate([target.value]);
|
||||
}
|
||||
onSelectChange(newId: string) {
|
||||
const selectedOption = this.allOptions
|
||||
.find((option: ComColPageNavOption) => option.id === newId);
|
||||
this.router.navigate([selectedOption.routerLink], { queryParams: selectedOption.params });
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user