我修改了其中一个入门 angularjs 演示,但无法让所需字段正常工作。我可以成功阻止空白提交,但在有效提交后会弹出“必填字段”。有谁知道我做错了什么?
$scope.addTodo = function () {
if ($scope.myform.$valid) {
$scope.todos.push({
text: $scope.todoText,
done: false
});
$scope.todoText = '';
}
};
<form name="myform">
<input type="text" ng-model="todoText" size="30" placeholder="add new todo here" ng-required="true">
<input class="btn-primary" type="submit" value="add" ng-click="addTodo()">
</form>