문제

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!

도움이 되었습니까?

해결책

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 === '#/'" ... >

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top