In my Ionic app I have a form with an input
field inside a form
, and a button
. Upon button
click some action should happen inside the controller
and the input
field should clear, but it does not happen. This seems like something really easy but I cant understand what it wrong. Please advise.
I read here, here and here, nothing helps.
The html:
<form novalidate name="customCategoriesForm">
<ion-list>
<ion-item>
<div class="item item-input item-stacked-label noBorder">
<span class="input-label">Create a new category</span>
<div class="catRow">
<input type="text"
id="newCategoryInput"
name="addNewCategory"
placeholder="Category name"
ng-model="addNewCategory"
ng-minlength="3"
required
>
<button ng-click="addCategory(addNewCategory)"
ng-disabled="!customCategoriesForm.addNewCategory.$valid"
class="button button-small button-outline button-positive catButton">Add</button>
</div>
</div>
</ion-item>
<ion-item>
...
</ion-item>
</ion-list>
</form>
The JS:
$scope.addCategory = function (newCategory) {
$scope.ExistingCategoriesArray.push(newCategory);
$scope.addNewCategory = "";
}
EDIT:
No error appears, nothing happens..