I need & larr; Return to the main page to appear below the origin on every page of my Angular application except the main page. Therefore, I would like to conditionally add a link and hide it with ng-hide if the url is already on the application’s home page (view).
I tried using Angular $location without success
<p ng-hide="location.hash == '#/'" class="container"><a href="#topics">← Back to Home</a></p>
I tried the following options:
ng-hide="location.hash == '#/' " //console.log shows true ng-hide="location.hash === '#/' " //console.log shows true ng-hide="location.hash == '' " //console.log shows false
I am puzzled because if I register the value location.hash == '#/' when I get true on the home page, then ng-hide should work.
Basically I try the 3rd approach given here: How to use Angular ng-hide based on the page / route I am currently in? But that does not work. The other two approaches on this page seem too complicated for what I'm trying to achieve.
What am I missing?
angularjs ng-show ng-hide
Tyler
source share