angularjs - How can I use ng-hide if $location.url == base (root) url? -


I want ← Back link to appear below the Incorporation on the Home page Leaving my angular app so I will add a conditional link and hide it using ng-hide if the URL is already on the app's homepage (see).

I tried to use the angular $ location service with any success

  & lt; P ng-hide = "location.hash == '# /'" class = "container" & gt; & Lt; A href = "# topics" & gt; & Amp; Larr; Back at home & lt; / A & gt; & Lt; / P & gt;   

I have tried the following differences:

  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'm wondering because if I login the value of location.hash == '# /' , then click on the true , So the ng-hide should work.

Actually I am trying to have 3 approaches listed here: But this is not working. The second two approaches on that page that I am trying to achieve are more complex.

What am I missing?

First things first, when you use the location hash or location.url you actually window. Using the location javascript object, you must use the $ location service provided by coal. So I will create in your controller:

  $ scope.currentPath = $ location.path ();   

and in your html:

  & lt; Div ng-hide = "currentPath === '/' '& gt; & lt; / div & gt;   

Although I caution about" # / "and" / " Well, I only use the html5 mode so I'm not sure what $ location.path will return but you can easily check it with console.log ($ location.path ()), though I think it Only "/" will return because it is the path to angular, it should not be cared #.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -