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.
Here's my code from the controller:
$scope.addElem = function () {
$scope.lista2.push({
com: null ? com = 'VUOTO' : com = $scope.newItem.com,
gruppo: null ? gruppo = 'VUOTO' : gruppo = $scope.newItem.gruppo
});
};
Here's the code from the HTML (I'm also using Bootstrap):
<form class="form-inline" name="input">
<input type="text" class="form-control col-5" ng-model="newItem.com" placeholder="Nome del comico" ng-keypress="$event.keyCode == 13 && addElem()" />
<input type="text" class="form-control col-5" ng-model="newItem.gruppo" placeholder="Gruppo del comico" ng-keypress="$event.keyCode == 13 && addElem()" />
<button class="btn btn-outline-secondary btn-sm col-2" type="submit" ng-click="addElem()">Inserisci</button>
</form>
newItemdefined in your controller?