Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable a button in ANGULARJS

i have angularJS 1.5.0-rc.2

I found on the internet that i can use the directive

data-ng-disabled="Expression"

But it won't disable a button.

What i tried :

<button data-ng-disabled="false">Select</button> // don't work
<button data-ng-disabled="loaded">Select</button> // don't work
<button data-ng-disabled="loaded != false">Select</button> // don't work

Loaded is defined in my controller as $scope.loaded = false.

How can i disable a button ? Thanks

like image 397
Vincent Ducroquet Avatar asked Apr 28 '17 09:04

Vincent Ducroquet


Video Answer


1 Answers

The button will be disabled only if the expression is true.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app ng-init="disableBtn=true">
  <button ng-disabled="disableBtn">test</button>
</div>
like image 111
Pengyy Avatar answered Oct 13 '22 10:10

Pengyy