我有一个简单的离子应用程序,它包含如下列表:
<ion-list ng-controller="MainController">
<ion-item ng-repeat="task in tasks">
{{task.title}}
</ion-item>
</ion-list>
在MainController中,我向任务集添加了一个新项:
.controller('MainController',function($scope,$ionicPopup){
$scope.tasks = [{title:"Clean dishes"},{title :"File Tax"},{title :"Take Pictures"}];
$scope.task = new Object();
$scope.showAddNewTaskDialog = function() {
var popup = $ionicPopup.show({
template:'<label class="item item-input"> <input ng-model="task.title" type="text" placeholder="Enter Task"/></label>',
title: 'New Task',
scope: $scope,
buttons :[
{ text :'Cancel'},
{
text: '<b>Save</b>',
type: 'button-positive',
onTap: function(e) {
$scope.tasks.push({ title :'new entry'});
}
}
]
});
}
})
但即使我在任务中添加新项目,列表也永远不会刷新。