javascript - Why is ng-disabled not working on button? -


my plunkr: http://plnkr.co/edit/4mkenjpczfbxy5aoilll?p=preview

enter image description here

<body ng-controller="mainctrl main">  <h1>hello plunker!</h1> <p>button should not disabled:</p>  <div ng-init="main.btndisabled = false">     <button ng-model="main.my_button"          ng-class="{ 'btn-success' : !tc.switching, 'btn-disabled' : tc.switching }"          disabled="main.btndisabled"          type="button"          class="btn btn-info btn-sm switch-btn">my button</button>   </div> 

angular

angular.module('app').controller('mainctrl', function($scope) {   vm = this;   vm.btndisabled = false; }); 

i found this answer here, didn't work in example.

the button disabled because there disabled attribute. enough browser know element must inactive. value disabled attribute doesn't matter, can anything.

this reason why angular provides ngdisabled directive, adds disabled attibute when expression evaluates true, , removes when it's false.

in case should use

<button ng-model="main.my_button"         ng-class="{ 'btn-success' : !tc.switching, 'btn-disabled' : tc.switching }"         ng-disabled="main.btndisabled"         type="button"         class="btn btn-info btn-sm switch-btn">my button</button>   

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -