title: Update input value on change using a parameter
body: <p>I am trying to replace any spaces in my input on change. I am using <code>ng-change</code> directive to accomplish that. I would normally write my code like this because I want the <code>removeInvalidCharacters</code> function to be reusable hence the model being passed as parameter.</p>
  <pre><code>&lt;input model=&quot;vm.model.code&quot; ng-change=&quot;vm.removeInvalidCharacters(vm.model.code)&quot; /&gt;
  </code></pre>
  <p>and JS</p>
  <pre><code>vm.removeInvalidCharacters = function(text) {
    text = text.replace(/ /g, '');
  };
  </code></pre>
  <p>I have read on the airbnb javascript style guide that this is a bad practice and we should return the value. To be exact we shouldn't &quot;mutate a parameter&quot; (<a href="https://github.com/airbnb/javascript#functions--mutate-params" rel="nofollow noreferrer">Never reassign parameters</a>). What is the right way to do it and still keep the reusable function?</p>