2014-02-11 89 views
0

我想在我的index.html中包含不同的標頭,其中一個用於用戶登錄時,另一個用於他不在時。這是我的想法:Angularjs包括基於位置的部分

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

控制檯打印爲true,但ng-if中的部分不能正常工作。我該如何解決這個問題,還是有更好的解決方案?

謝謝!

+1

'location'是最可能不在導致問題的「範圍」上。 –

回答

1

內部控制器,基於位置的哈希創建範圍的項目:

$scope.currentHash = location.hash;

,然後使用您的視圖範圍的項目:

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