Answer the question
In order to leave comments, you need to log in
How to update View from another scope?
The essence of the problem:
I have a test registration form using LocalStorage. After the user registers, the data enters the local store, the user is redirected to the user's page and the menu changes according to the rules ng-if
. And so View does not change, only it is shown that the link is new. But when you press F5
, when the controller is triggered, naturally everything is normal.
Details:
1. service ` Authentication
`. A method that puts the form data in ` localStorage
` and redirects the user to another link:
Authentication.registration = function(data) {
localStorage.setItem('registrationData', JSON.stringify(data));
$location.path('/userPage');
}
Authentication.ifLog = function() {
// verify if the user exists in localStorage
}
Link
`:$scope.registration = function(form) {
Authentication.registration(
};
Base
`' is the controller where I call the ifLog
service ` ` method ` Authentication
` .<li ng-if="Base.logined"><a href="#userPage">UserPage</a></li>
<li ng-if="!Base.logined" ng-click="Base.toggleModal()">LogIn</li>
<li ng-if="Base.logined">{{Base.user.name}}</li>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question