0
我在另一個ng-repeat內部的ng-repeat內部有一個ng-show。那個ng-show裏面有一個按鈕。當我點擊按鈕時,我的範圍被正確更新,但是在我刷新頁面之前,ng-show不會改變。在角度上,爲什麼我的ng-shows沒有更新以反映當前的範圍?
模板:
<div ng-repeat="quest in quests">
<p ng-show="{{quest.progress === 0}}">You and goat have found a castle.</p>
<p ng-repeat="step in quest._steps">
<span ng-show="{{quest.progress === step.order}}">You are here</span>
<span ng-show="{{quest.progress + 1 === step.order}}">Goat Says: {{step.flavorText}} {{step.description}}<button ng-click="nextStep(quest)">Step Complete!</button>
</span>
</p>
控制器:
$scope.nextStep = function(currentQuest, i) {
currentQuest.progress++;
console.log('$scope.quests', $scope.quests);
questService.editQuest(currentQuest._id, currentQuest)
.then(function(response) {
});
};
所以現在,我的數據庫更新正確的,當我點擊,和$ scope.quests的執行console.log顯示正確更新任務對象(我不明白,因爲我正在增加currentQuest.progress而不是$ scope.quests [$ index]或其他,但由於範圍更新我不在乎),那麼爲什麼地球上沒有顯示和隱藏正確的ng顯示?
可能用於調試的好主意是輸出quest.progress和步驟值在你的模板裏面。 – Sarhanis