sl_bug sl_bug - 1 month ago 11
AngularJS Question

How to apply changes in angularjs (ng-show)?

I have 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
is getting set to true, but div with error message is not being shown. How to show it?

Answer

Angular doesn't re-check the value of your invalid_credentials variable. Using a function as your ng-show argument should work.