Reputation: 8705
I have a angular modal window (for login). When user hits submit, i need to change the view to a home page (/myhome).
But doing $location.path = "/myhome" does not seem to be working from modal controller.
I open the Modal as follows:
$scope.openLoginModal = function () {
var modalInstance = $modal.open({
templateUrl: 'resources/html/login.html',
controller: 'loginController',
windowClass: 'app-modal-window'
});
};
And in my loginController, when user hits Submit i invoke doLogin function:
myApp.controller('loginController', function($scope, $modalInstance, $location, $http) {
....
$scope.dologin = function () {
...
$location.path="/myhome";
$modalInstance.dismiss('cancel');
....
}
But the view never changes to /myhome.
Any ideas? Or alternative ways?
Upvotes: 2
Views: 1174
Reputation: 3820
You're setting $location.path incorrectly. It's a setter function so the syntax is:
$location.path("/myhome");
Try that and see how it goes.
Upvotes: 2