amigo21
amigo21

Reputation: 391

Angular $location.path expression for a URL

I'm trying to hide a header element in my AngularJS app based on certain paths. So far I have this:

    <header logo="appModel.config.logoUrl" ng-hide="currentPath==='/brandHealth/metricsWidget'"></header>

This works fine but when I change currentPath to '/brandHealth/*' it does not work. I need it to work for all URLs within that brandHealth subset. Any way to do this?

Thanks in adv

Upvotes: 0

Views: 82

Answers (1)

levi
levi

Reputation: 22697

Change your condition to:

'/brandHealth/metricsWidget'.split('/')[0] === currentPath

But, you should do that on your controller

$scope.containsPath = '/brandHealth/metricsWidget'.split('/')[0] === currentPath

Then in your header element

<header logo="appModel.config.logoUrl" ng-hide="containsPath"></header>

Upvotes: 1

Related Questions