title: Bind boolean value in Angularjs
body: <p>I want to bind an expression to a ng-disabled or ng-class attribute and have it re-evaluate whenever the properties change. If I have the expression in the html it all works but makes for terrible readability:</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-html lang-html prettyprint-override"><code>&lt;div ng-class="{disabled: $ctrl.form.$valid &amp;&amp; $ctrl.foo &amp;&amp; $ctrl.bar &amp;&amp; $ctrl.goo }" &gt;
    bla bla bla
  &lt;/div&gt;
  &lt;button ng-disabled="$ctrl.form.$valid &amp;&amp; $ctrl.foo &amp;&amp; $ctrl.bar &amp;&amp; $ctrl.goo" /&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I'd prefer to have a property in my class definition:</p>
  
  <pre><code>this.isValid = this.form.$valid &amp;&amp; this.foo &amp;&amp; this.bar &amp;&amp; this.goo;
  </code></pre>
  
  <p>and bind to this property like so :</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-html lang-html prettyprint-override"><code>&lt;div ng-class="$ctrl.isValid" &gt;
    bla bla bla
  &lt;/div&gt;
  &lt;button ng-disabled="$ctrl.isValid" /&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>If I do the latter the expression only evaluates once when the controller evaluates. Is there a way to do this?</p>