我的控制器有问题。我使用离子(角度)和js数据。当我通过addItem()
添加一个新项目时,只有当我通过F5重新加载页面时才会看到它。
这里是我的代码:
.controller('FooCtrl', function($scope, $ionicPlatform, foo) {
$ionicPlatform.ready(function() {
foo.findAll().then(function (items) {
$scope.items = items;
});
});
$scope.item = {};
$scope.addItem = function() {
foo.create({ name: $scope.item.name });
};
})
我有什么做的,看到withous首先按F5的新元素在我的浏览器窗口?
你必须'push'新项目到您的集合:'$ scope.items.push($ scope.item)' – DRobinson