title: Angular directive to set the disabled attribute
body: <p>I want to be able to set the disabled attribute of any controls from two places. On the control itself, based on rules that are hardcoded in the view itself. And from a directive based on rules defined in an external service.</p>
  
  <p>When the directive sets disabled to true, this should not be overriden by what's defined on the control. However when the directive sets disabled to false, then what is defined on the control should trigger. </p>
  
  <p>I hope it makes sense. So far I have this code, but it does not work the way I want.</p>
  
  <pre><code>&lt;input check-edit-matrix type="checkbox" 
         data-ng-model="model.isPrivate" 
         ng-disabled="model.isDeleted || model.isConfidential"  /&gt;
  </code></pre>
  
  
  
  <pre><code>(function () {
    'use strict';
  
    var directiveId = 'checkEditMatrix';
  
    angular.module('common.directives')
           .directive(directiveId, ['dataService', directiveFunc]);
  
    function directiveFunc(dataService) {
      return {
        restrict: 'A',
          scope: { 
          },
          link: function (scope, element, attrs) {
  
            attrs['disabled'] = 'disabled';
  
            //if (attrs['disabled'] === 'disabled') {
            //    alert('already disabled !')
            //}
          }
        };
      }
  })();
  </code></pre>