我注意到,在離子待辦事項應用示例中,如果我取消模態並將其重新打開,舊模式/舊待辦事項信息仍保留在模態中。清除/重置舊模態數據的最佳位置是什麼,以便在取消或提交模態表單字段後始終有新的空白字段?如何清除離子角TODO示例中的模態
我是否應該清空或清除任務對象somehwere?在關閉時手動重置字段並創建?添加一個處理程序到某種隱藏事件?
這裏的角/離子例如:
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>