我有一个表单,它在我的待办事项列表数组中添加项目。 但是,如果输入字段为空,我的函数将为我的数组添加一个空值。使用angularJS验证输入文本
什么是验证表单的最佳方法?
<form name="formaddtodo" ng-submit="todoList.addTodo()">
<input type="text" ng-model="todoList.todoText" ng-minlength="1" size="30"
placeholder="Voeg nieuwe todo toe">
<input class="btn-primary" type="submit" value="voeg toe">
</form>
这里是我的功能
todoList.addTodo = function() {
todoList.todos.push({text:todoList.todoText, done:false});
todoList.todoText = '';
};
没有确认,但是我很好奇的最好办法是验证什么。
预先感谢您!