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