Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using <code>ng-disabled</code> worked just fine in this <a href="http://plnkr.co/edit/stdkjN?p=preview" rel="noreferrer">example</a>. No matter how furiously I clicked the console message only populated once.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.submitData = function() { $scope.buttonDisabled = true; console.log("button clicked"); } function augment() { var name, fn; for (name in $scope) { fn = $scope[name]; if (typeof fn === 'function') { if (name.indexOf("$") !== -1) { $scope[name] = (function(name, fn) { var args = arguments; return function() { console.log("calling " + name); console.time(name); fn.apply(this, arguments); console.timeEnd(name); } })(name, fn); } } } } augment(); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt; &lt;html ng-app="plunker"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;AngularJS Plunker&lt;/title&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.js"&gt;&lt;/script&gt; &lt;script src="app.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body ng-controller="MainCtrl"&gt; &lt;input type="button" ng-click="submitData()" ng-disabled="buttonDisabled" value="Submit" /&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p> <p>I was curious exactly how long it takes for angular to apply the changes to the <code>buttonDisabled</code> flag. If you check the console in the plunker <a href="http://plnkr.co/edit/stdkjN?p=preview" rel="noreferrer">example</a> it displays how long it takes the <code>$eval</code> and <code>$apply</code> methods to execute. On my machine it took an average of between 1-2 milliseconds.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload