使用Ionic框架在AngularJS中提交表单后,输入不会清除
Input won't clear after form submission in AngularJS using Ionic framework
我有这个奇怪的问题。当我清除控制器中的模型时,使用 ng-model 绑定到模型的输入字段在提交表单时不会清除。
控制器
angular.module('starter.controllers', [])
.controller('DashCtrl', ["$scope", function($scope) {
$scope.clearInput = function() {
console.log("I get there...");
//Here's the issue!!! It's not working as expected!
$scope.message = "";
};
}]);
模板
<ion-view title="Dashboard">
<ion-content class="padding">
<form name="myform" ng-submit="clearInput()">
<label class="item item-input">
<input type="text" ng-model="message"/>
</label>
<button type="submit" class="button button-positive" >
button-positive
</button>
</form>
</ion-content>
</ion-view>
我得到控制台输出"我到达那里",因此该功能被激活。我在这里错过了什么?
clearInput()
和ng-model
在输入值更改后引用不同的范围。请参阅此SO答案以获取更深入的解释。
相关文章:
- 单击jquery清除输入值
- php页面,该页面在清除值后接受输入
- 在Chrome中重新加载页面后清除表单输入值
- 当在输入框中聚焦时,清除页面上的所有间隔
- 改变“;onClick"这个jQuery的操作从清除输入文本改为将输入文本添加到下面的列表中
- 如何在表单提交后清除输入字段
- 当您发布聊天消息时,聊天输入不会清除
- IE 输入清除图标有时不会触发更改事件
- 输入文本区域的清除按钮
- Magento自定义选项-清除输入字段问题
- 点击提交后如何清除输入字段
- 如何正确清除AngularJS控制器输入无效的表单
- 清除间隔在鼠标输入上不起作用
- 如何从文本区域输入中清除文本
- 清除输入字段值-STCombobox时出现意外的JS行为
- 在追加时清除所有输入文本框值
- 我可以重置文本输入而不清除它吗
- Email提交输入清除/css在iphone Safari或Chrome上不起作用
- 停止输入清除onFocus
- 输入清除问题