[英]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答案以獲得更深入的解釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.