How can I disable other buttons when I press one button in angularjs -


is possible in angular? when press 1 single button element, other button elements automatically disabled. saw similar question looking in pure angularjs.

<html ng-app>   <button ng-model="button" > abc  </button>    <button ng-disabled="button"> def </button>    <button ng-disabled="button"> ghi </button> </html> 

you can bind ng-click event 3 of buttons, passing identifier function (i.e. id of button. function bind variable scope, use determine if ng-disabled should active or not.

for example, in controller have similar to:

    $scope.selectedbutton;      $scope.selectbutton = function(id) {         $scope.selectedbutton = id;     } 

then, in html; revise take in ng-click , ng-disabled considerations mentioned above.

<html ng-app ng-controller="somecontroller">   <button ng-disabled="selectedbutton && selectedbutton != 'abc'" ng-click="selectbutton('abc')">abc</button>    <button ng-disabled="selectedbutton && selectedbutton != 'def'" ng-click="selectbutton('def')">def</button>    <button ng-disabled="selectedbutton && selectedbutton != 'ghi'" ng-click="selectbutton('ghi')">ghi</button> </html> 

note, logic of checking if selectedbutton , selectedbutton not equal foo, determine button has been selected, variable set scope.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -