title: AngularJS dynamically change ngMask
body: <p>I need to dynamically change a mask. </p>
  
  <p>So I'm making this directive to handle it:</p>
  
  <pre><code>link: function($scope, $element, $attrs, ngModel) {
      $scope.$watch($attrs.ngModel, function(value) {
          if (value.length &gt; 4) {
              $element.attr('mask', '9999  9999');
          } 
          else {
              $element.attr('mask', '99999999');
          }
      });
  }
  </code></pre>
  
  <p>The mask is being applied, I'm checking the DOM, but there's no effect whatsoever.</p>
  
  <p>What I am missing here?</p>