title: How to check for an empty string in AngularJS?
body: <p>I'm trying to check if a string is empty in a form, setting a default value if the answer is true, or passing the actual value if the string isn't empty.<br>
  Here's my code from the controller:</p>
  
  <pre><code>$scope.addElem = function () {
      $scope.lista2.push({
          com: null ? com = 'VUOTO' : com = $scope.newItem.com,
          gruppo: null ? gruppo = 'VUOTO' : gruppo = $scope.newItem.gruppo
      });
  };  
  </code></pre>
  
  <p>Here's the code from the HTML (I'm also using Bootstrap):</p>
  
  <pre><code>&lt;form class="form-inline" name="input"&gt;
      &lt;input type="text" class="form-control col-5" ng-model="newItem.com" placeholder="Nome del comico" ng-keypress="$event.keyCode == 13 &amp;&amp; addElem()" /&gt;
      &lt;input type="text" class="form-control col-5" ng-model="newItem.gruppo" placeholder="Gruppo del comico" ng-keypress="$event.keyCode == 13 &amp;&amp; addElem()" /&gt;
      &lt;button class="btn btn-outline-secondary btn-sm col-2" type="submit" ng-click="addElem()"&gt;Inserisci&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>