Control Code:
$scope.$on('$locationChangeStart', function () {
var path = $location.path();
var adminPath = '/admin/' ;
if(path.match(adminPath)) {
$scope.adminContainer= function() {
return true;
};
});
HTML
<div class="container" ng-show="adminContainer()">
<div ui-view></div>
</div>
The code currently detects the URL matching http://localhost/angapp/#/login
, but now I have additional admin URLs like below
http://localhost/angapp/#/admin/users
http://localhost/angapp/#/admin/usersGrp
http://localhost/angapp/#/admin/XYX
I want to dynamically match any URL that starts with /admin/ followed by a specific module name and display the appropriate HTML.
How can I utilize location.path()
to detect Admin URLs and show/hide the div accordingly?