angularjs - ng-show directive not working properly -


i using ng-show directive show/hide alert box in ui:

<alert ng-show="{{showalert()}}">{{showalert()}}</alert>

my controller code is:

$scope.showalert = function () { return userform.$invalid || false; };

though getting correct value content of alert , able see booelan values in ui alert still keeps on showing.

any idea?

  1. ng-show accepts expression.
  2. userform lives in $scope.

template:

<span ng-show="showalert()">form invalid!!</span> 

controller:

$scope.showalert = function() {   return $scope.userform.$invalid || false; }; 

or, simply:

<span ng-show="userform.$invalid">form invalid!!!</span> 

and link working example: http://plnkr.co/edit/nlc1dbtk8vazbbgjnlb0


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -