我希望← 返回主页链接出现在我的 Angular 应用程序的每个页面的导航下方,主页除外。所以我想有条件地添加链接并使用ng-hide
如果 url 已经在应用程序的主页(视图)上隐藏它。
我尝试使用 Angular 的$location
服务但没有成功
<p ng-hide="location.hash == '#/'" class="container"><a href="#topics">← Back to Home</a></p>
我尝试了以下变体:
ng-hide="location.hash == '#/' " //console.log shows true
ng-hide="location.hash === '#/' " //console.log shows true
ng-hide="location.hash == '' " //console.log shows false
我很困惑,因为如果我location.hash == '#/'
在主页上记录我得到的时间值true
,那么ng-hide
应该可以工作。
基本上我正在尝试此处列出的第三种方法: 如何根据我当前所在的页面/路线使用角度 ng-hide?但它不起作用。对于我想要实现的目标,该页面上的其他两种方法似乎过于复杂。
我错过了什么?