How to apply changes in angularjs (ng-show)?
I have a form
<form ng-controller="SessionController" name="login_form"> <div class="hide" ng-show='invalid_credentials'>Invalid email/pass</div> <input type="submit" value="Login" ng-click='login()'> </form> Controller:
utApp.controller('SessionController', ($scope, $cookieStore, ClientService) -> $scope.login = -> ... if something $scope.invalid_credentials = true return on some conditions $scope.invalid_credentials set to true, but the div with the error message does not appear. How to show it?
+6
2 answers
The accepted answer will work ... However, what you really need to do is use $ scope. $ apply
utApp.controller "SessionController", ($scope, $cookieStore, ClientService) -> $scope.login = -> if something $scope.$apply (s) -> s.invalid_credentials = true Typically, when updating the scope and it does not update the user interface ... because you need to use $ apply .
+2