- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2018 11:25 AM
I'm trying to watch for when $scope.page changes. My goal is to update my menu to highlight the active menu selection.
It works great on load by looking for the menu.item that matches $scope.page, but after the user selects a new page from the menu my highlight becomes out of date.
Is there an event that fires when a new page is loaded?
I've tried to piggy back off the 'sp_loading_indicator' event, but it seems to fire before the $scope.page variable is updated.
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2018 09:07 PM
Hi Kevin,
Try to get the URL of the page (window.location or this.location) and check for the page (best create a table for menu item and page mapping). if the current page user is in matches one of the items in the table, that will return the menu item and highlight the menu item accordingly.
2nd option = pass the sysparm_xyz='blahblah' when someone goes to the menu items, and look for $sp.getParameter('xyz')='blahblah' in the menu and highlight the option if returns true.
Hope this helps.
Regards
Prasun
P.S.- Mark Helpful or correct if helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2018 09:07 PM
Hi Kevin,
Try to get the URL of the page (window.location or this.location) and check for the page (best create a table for menu item and page mapping). if the current page user is in matches one of the items in the table, that will return the menu item and highlight the menu item accordingly.
2nd option = pass the sysparm_xyz='blahblah' when someone goes to the menu items, and look for $sp.getParameter('xyz')='blahblah' in the menu and highlight the option if returns true.
Hope this helps.
Regards
Prasun
P.S.- Mark Helpful or correct if helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2018 06:30 AM
OK, I wound up using the location to help track it. It isn't perfect, since I have to track the root page as /<portal name> and ?id=index as the same, but it does work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 11:42 PM
To listen for a URL change one option is to use the $locationChangeSuccess on the $location service.
$scope.$on('$locationChangeSuccess', function () {
//https://x.service-now.com/sp_config?id=widget_editor
var searchObject = $location.search();
c.activePage = searchObject.id.slice();
//Do something with c.activePage, like a conditional class
});
A conditional class in the HTML could be something like
<div ng-class="{'strong': c.activePage == 'widget_editor'}">Editor</div>