In my AngularJS app's signup process, I'm constantly updating a user object.
This may be the wrong way to do it, but I'm using one "signup" controller for all of these signup steps (as the logic in the steps is all very similar and it makes for neater code rather than making a separate "signup1", "signup2" etc controller for each view.
I have a promise that returns userInfo
from my database:
.service('userInfo', function ($http, $cookies) {
var userId = $cookies.id;
console.log("UI Cookies", $cookies);
var promise = $http.get('/api/findProfile/' + userId, { cache: false}).
success(function (data) {
var userInfo = data;
console.log("This is fresh data!") // This logs the first time I load my page, but never again
return userInfo;
}).error(function(data) {
console.log("ERROR")
return userInfo
});
return promise;
})
When going from one signup step to the next, I update the profile info on MongoDB then load the next page. If I load the page via changing $location('')
from my controller, I get old userInfo
that hasn't been updated in my database. However, if I do a full page refresh I get the correct, updated userInfo
.
Is this a caching issue? I've tried passing {cache: false}
to my $http
promise but I'm not getting fresh data (as denoted by the console.log("This is fresh data!")
; rather, I'm getting cached data back.
How can I resolve this beyond forcing a full-page reload in Angular?