Disable submit button after one click in angularJS

sravs17991 picture sravs17991 · Jul 27, 2016 · Viewed 15.8k times · Source

I would like to disable button after one click.

Code:

<button id="submitRequest" class="btn btn-primary btn-active"
        ng-disabled="!frmRequest.$valid||!r.DataUseAgreement||(!chkBMT&&!chkOncore&&!chkCAISIS&&!chkLIMS&&!chkFCR)"
        ng-click="SaveData()">
  <i class="fa fa-save"></i> Submit
</button>

How to disable this one after one click?

Thanks!

Answer

EddNewGate picture EddNewGate · Jul 27, 2016

Simple. You write to element a bit of javascript, like onclick="this.disabled=true" .

<button id="submitRequest" onclick="this.disabled=true" class="btn btn-primary btn-active" ng-disabled="!frmRequest.$valid||!r.DataUseAgreement||(!chkBMT&&!chkOncore&&!chkCAISIS&&!chkLIMS&&!chkFCR)" ng-click="SaveData()"><i class="fa fa-save"></i> Submit</button>