Sam Sam -4 years ago 189
AngularJS Question

how to disable or enable button on angularjs?

I have used 2 button in the form. I want to disable button1 on initialisation though I have given

but whenever user clicks on button2, button1 get enabled. Can anyone tell me how to do this in angularjs ?

Answer Source

You don't need to do anything in the controller if you are not working with the scope variable inside the controller.

So just do something like:

<script src=""></script>
        <div ng-app="app" ng-controller="ctrl">
          <button ng-disabled="first !== true"> one</button>
          <button ng-click="first = true"> two</button>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download