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 I tried to use the angular I have tried the following differences: I'm wondering because if I login the value of 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: and in your html: 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 #. ng-hide if the URL is already on the app's homepage (see).
$ 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;
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 == '# /' , then click on the
true , So the
ng-hide should work.
$ scope.currentPath = $ location.path ();
& lt; Div ng-hide = "currentPath === '/' '& gt; & lt; / div & gt;
Comments
Post a Comment