我注意到,在离子待办事项应用程序示例中,如果我取消模式并再次打开它,陈旧/旧的待办事项信息仍保留在模式上。清除/重置旧模式数据的最佳位置是什么,以便在我取消或提交模式表单字段后它总是有新的空白字段?
我应该在某个地方清空还是清除任务对象?在关闭和创建时手动重置字段?将处理程序添加到某种隐藏事件?
这是角度/离子示例:
http://ionicframework.com/docs/guide/building.html
和相关的代码片段
// Called when the form is submitted
$scope.createTask = function(task) {
$scope.tasks.push({
title: task.title
});
$scope.taskModal.hide();
task.title = "";
};
// Open our new task modal
$scope.newTask = function() {
$scope.taskModal.show();
};
// Close the new task modal
$scope.closeNewTask = function() {
$scope.taskModal.hide();
};
和模态
<div class="modal">
<!-- Modal header bar -->
<ion-header-bar class="bar-secondary">
<h1 class="title">New Task</h1>
<button class="button button-clear button-positive" ng-click="closeNewTask()">Cancel</button>
</ion-header-bar>
<!-- Modal content area -->
<ion-content>
<form ng-submit="createTask(task)">
<div class="list">
<label class="item item-input">
<input type="text" placeholder="What do you need to do?" ng-model="task.title">
</label>
</div>
<div class="padding">
<button type="submit" class="button button-block button-positive">Create Task</button>
</div>
</form>
</ion-content>