Question

I want to include different headers in my index.html, one for when the user is logged in, and one for when he's not. This is my idea:

<script>console.log(location.hash === '#/')</script>
<div ng-if="location.hash === '#/' " id="header" ng-include="'partials/homeHeader.html'"></div>

The console prints true, but the part in ng-if doesn't work well. How can I solve this, or is there a better solution?

Thanks!

Was it helpful?

Solution

Inside your controller, create a scope item based on the location hash:

$scope.currentHash = location.hash;

And then use the scope item in your view:

<div ng-if="currentHash === '#/'" ... >

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top