Angular - Checking if a field is empty
<p>Bit of a trivial one here however am new to Angular so excuse me.</p>

<p>Whenever I have an input field - I only want an action to occur if the field actually contains some valid content.</p>

<p>What i find I'm having to do is first instantiate a variable, then assign that to whatever input there is then do a boolean check in a if.</p>

<p>Is the the correct way to go around this? If i don't instantiate the variable (or don't use one at all) i run into getting <code>undefined</code> error:</p>

<pre><code>var textToSearch = '';
textToSearch = $scope.main.searchInputField.trim();

if (textToSearch){
      $location.path('/search/'+textToSearch);
}
</code></pre>

<p>Also (on another note)
I'm sanitising everything on the server side however on Angular/client side is there a quick and easy function I can use?</p>

<p>Thanks</p>