user3197307 user3197307 - 5 months ago 24
AngularJS Question

AngularJs path not changing, even after apply

I have a quick question about the chaning of a route trough a custom directive. I set up a menubar diretive and set up a link function. Everything in this function works correctly, but the chaning of the URL trough the

does not. Even after using
, it does not change.

function (module, namespace) {
module.directive(namespace + '.menubarDirective', function ($location, $rootScope) {
return {
restrict: 'EA',
replace: 'true',
templateUrl: 'scripts/app/menubar/views/menubar.html',
scope: {},
controller: function () {
link: function (scope, element, attrs) {

$("#menubarStoreButton").click(function () {


To be clear, I use
and $location and
are defined. The weird thing is,
before the replace gives a empty path. Also, the placement of the class 'active' works as intended.



try using $timeout -

$("#menubarStoreButton").click(function() {
    $timeout(function() {