title: AngularJs input field with ng-model with filter issue
body: <p>I have several input fields and i wish to validate user input if is only white space. I try with directive or with filter. I prefer not to use $watch because there are too many input fields. What I need is: If User set only blank spaces in input field some function or directive to clean this white spaces.
  I can do this with jQuery or vanilla JS, but I prefer this result to be in angular way.</p>
  
  <p>Where I`m wrong in directive or in filter</p>
  
  <p>This is my code: </p>
  
  <pre><code>angular.module('app')
  .directive('customSpaceValidation', ['$filter', function ($filter) {
      return {
          require: '?ngModel',
          link: function (scope, elem, attrs, ctrl) {
              if (!ctrl.replace(/\s/g, '').length) {
                  ctrl = "";
              }
              return ctrl;
          }
      };
  }])
  .filter('nospace', function () {
      return function (value) {
          if (!value.replace(/\s/g, '').length) {
              value = "";
          }
          return value;
      };
  })
  </code></pre>
  
  <p>this is html with directive: </p>
  
  <pre><code>&lt;input type="text" class="form-control" id="inputKey" ng-model="channel.key" customSpaceValidation data-ng-trim="false" ng-required="true" name="inputKey" required /&gt;
  </code></pre>
  
  <p>this is html with filter</p>
  
  <pre><code>&lt;input type="text" class="form-control" id="inputKey" ng-model="channel.key | filter : nospace" data-ng-trim="false" ng-required="true" name="inputKey" required /&gt;
  </code></pre>
  
  <p>Filter trow exceptions:</p>
  
  <pre><code>ng-table-export.src.js:45 TypeError: ngModelSet is not a function
  at NgModelController.$$writeModelToScope (ng-table-export.src.js:45)
  at writeToModelIfNeeded (ng-table-export.src.js:45)
  at ng-table-export.src.js:45
  at validationDone (ng-table-export.src.js:45)
  at processAsyncValidators (ng-table-export.src.js:45)
  at NgModelController.$$runValidators (ng-table-export.src.js:45)
  at NgModelController.$$parseAndValidate (ng-table-export.src.js:45)
  at NgModelController.$commitViewValue (ng-table-export.src.js:45)
  at ng-table-export.src.js:45
  at Scope.$eval (ng-table-export.src.js:45)
  </code></pre>