.controller('PizzaCtrl', ['$scope','$state','$ionicLoading',
function($scope, $state, $ionicLoading) {
$scope.$emit('menu-refresh-request');
$scope.$on('menu-refresh-response', function(event) {
console.log("pizza");
$scope.$broadcast('scroll.refreshComplete');
$scope.items = $scope.$parent.menu.pizze;
console.log($scope.items[1].price);
$ionicLoading.hide();
});
$scope.doRefresh = function() {
$scope.$emit('menu-refresh-request');
};
}])
數據全部檢出。正確的項目信息被記錄到控制檯。但是,我的視圖中的ng-repeat="item in items"
指令不會使用披薩項目進行更新。
我嘗試在事件監聽器中使用$scope.$apply
和$scope.$digest
,但控制檯發出錯誤消息說摘要已在進行中。
另外值得注意的是,這個控制器有兩個兄弟控制器,與這個控制器具有相同的邏輯,除了菜單的不同部分。在我點擊進入狀態之前,console.log("pizza")
語句不會被執行。
我的觀點沒有更新是否有明確的理由?
<ion-refresher pulling-text="Updating Menu..." on-refresh="doRefresh()">
<div class="list menu-list">
<a class="item menu-item" ng-repeat="item in items" ui-sref="menu.pizza-detail({ index: $index })">
<div class="row">
<h3 class="row" ng-bind="item.name"></h3>
<div class="row">
<div class="list-price col col-15">
<h4 class="list-value" ng-bind="item.price"></h4>
</div>
<div class="list-description col col-85">
<p ng-bind="item.description"></p>
</div>
</div>
</div>
</a>
</div>
我們可以看到你的ng-repeat代碼嗎? – Scottie
你有沒有去... –
這看起來很可疑(是披薩還是餡餅?),$ scope.items = $ scope。$ parent.menu.pizze; –