samedi 27 décembre 2014

Setting the path in ui-router via $location.path() does not change $state.current

I am initializing my angular controller with the following code:



console.log($state.current);
$location.path('/newpath');
console.log($state.current);


The $state.current variable is not being changed though the path has changed. I tried $scope.$apply() but this gives me an digest cycle already in progress error.


Note that this doesn't work in my test either:



it('should route /newpath to the newpath view', function () {
$location.path('/newpath');
$rootScope.$apply();

console.log($location.path());
console.log($state.current);
expect($state.current.templateUrl).to.equal('app/newpath/newpath.html');

});

Aucun commentaire:

Enregistrer un commentaire