I'm trying to create Bootstrap 3 navbar on which when I tap an tab it's active, with this answer. However, when I tried to write the above code and run the app, then for some reasons $location.path()
doesn't have any values.
When I tried to debug the output, using console.log($location);
in my Angular function above, then it returned the following:
LOC =
Ob {$$protocol: "http", $$host: "localhost", $$port: 3000, $$parse: function, $$compose: function…}
$$absUrl: "http://localhost:3000/blog"
$$compose: function (){var c=bc(this.$$search),e=this.$$hash?"#"+Bb(this.$$hash):"";this.$$url=Ac(this.$$path)+(c?"?"+c:"")+e;this.$$absUrl=
$$hash: ""
$$host: "localhost"
$$parse: function (d){var e=pa(b,d)||pa(c,d),e="#"==e.charAt(0)?pa(a,e):this.$$html5?e:"";if(!t(e))throw Nb("ihshprfx",d,a);Cc(e,this,b);d=this.$$path;var g=/^\/?.*?:(\/.*)/;0===e.indexOf(b)&&(e=e.replace(b,""));g.exec(e)||(d=(e=g.exec(d))?e[1]:d);this.$$path=d;this.$$compose()}
$$path: "" // set to path
$$port: 3000
$$protocol: "http"
$$replace: false
$$rewrite: function (a){if(Za(b)==Za(a))return a}
$$search: Object
$$url: ""
__proto__: Object
And since the above linked code uses $location.path()
, I cannot toggle the active/inactive in my Bootstrap navbar.
Why does it return the undefined $location.path()
? I use the latest Angular version and Bootstrap 3. And on what occasions/circumstances do the $location.path()
return something and when nothing?