The application uses angularjs. I have a navigation bar which opens pages and also another UI which also opens the same pages(same links).
I am using $locationChangeStart to toggle open the sub-menu in the navbar when I open a page from the other UI.
When I open the same page from the from the navigation bar, the toggle happens and the sub-menu of navbar closes.
$rootScope.$on("$locationChangeStart", function(event, next, current) {
$rootScope.hashUrl = next.split('#').pop();
$rootScope.hashUrl = '#' + $rootScope.hashUrl;
console.log($rootScope.hashUrl, "URL"); //#!/addflats
$rootScope.addActiveToSidebarElement(event, next, current);
});
The function the locationChangeStart calls:
$rootScope.addActiveToSidebarElement = function(event, next, current) {
$rootScope.anchorElement = $("a[href='" + $rootScope.hashUrl + "']");
if (parentLi.hasClass('associationChildLi')) {
$rootScope.anchorElement.addClass('selectedSideBarChildActive');
$('.associationUl').slideToggle();
}
}
Both links(from navigation bar and other UI) cause the route change. How do I find which link caused the route to change?
from find which link caused route to change
No comments:
Post a Comment