I am attempting to make a simple authentication service by sending a Post to a php file, I need it to load the home page partial on my ng-view
when its successful.
This is what I tried :
function loginCtrl($scope, $http, $location){
$http.post(url,data).success(function(data){
$location.path('/home');
});
}
Results in my url changing but ng-view
not updating. It updates when I manually refresh the page.
(routes have been configured properly at the $routeProvider
, I have tested redirecting this with a standalone function not as a callback and it works )
I have also tried defining $location.path('/home')
as a function and then calling it on the callback it still doesn't work.
I did some research and found some articles stating this happens when using another third party plugin, I am only loading angular.js
Any insights or pointers to some study material will be great
Instead of using
success
, I change it tothen
and it works.here is the code:
Use : $window.location.href = '/Home.html';
it's very easy code .. but hard to fined..
I am doing the below for page redirection(from login to home page). I have to pass the user object also to the home page. so, i am using windows localstorage.
And it worked for me.
There is simple answer in the official guide:
Source: https://docs.angularjs.org/guide/$location
Here is the changeLocation example from this article http://www.yearofmoo.com/2012/10/more-angularjs-magic-to-supercharge-your-webapp.html#apply-digest-and-phase