在角度中,为什么我的 ng-show 不更新以反映当前范围
In angular, why are my ng-shows not updating to reflect the current scope?
我在另一个ng-repeat的内部有一个ng-show。该ng-show内部有一个按钮。当我单击该按钮时,我的范围已正确更新,但在我刷新页面之前,ng-show 不会更改。
模板:
<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 的控制台.log显示了一个正确更新的任务对象(我真的不明白,因为我正在增加 currentQuest.progress 而不是 $scope.quests[$index] 或其他什么,但既然范围已更新,我不在乎),那么为什么没有显示和隐藏正确的 ng-show??
因为您正在使用插值大括号{{}}
... ng-show
直接读取表达式。许多核心指令都是相同的。
内插大括号用于将文本打印到 dom 中
改变
ng-show="{{quest.progress === 0}}"
自
ng-show="quest.progress === 0"
相关文章:
- ngDialog-弹出窗口未更新范围变量
- 无法使用编程加载的属性更新范围滑块.js
- 角度文件上传更新范围在完成项上
- AngularJS摘要周期偶尔无法更新范围
- Angular:从工厂更新范围不起作用
- NG模型对我来说是矫枉过正的.任何仅在单击按钮时更新范围的替代方案,而不是每次都更新范围
- Angularjs 可编辑的字体头不更新范围
- 通过选中复选框更新范围
- 如何更新范围值
- 事件的角度更新范围
- 角度不更新范围更改时的模板
- 更新范围时不调用 Angular 指令
- AngularJS更新范围$q
- 如何动态更新范围滑块
- 尝试使用Firebase facebookconnect和AngularJS更新范围变量时出现问题
- Angular ng src在更改图像源时不更新范围
- 在$index达到某个数字后更新a范围值
- Angular-当Factory数据发生更改时更新范围
- 在视图中使用compile in指令和ng repeat的组合会阻止正确更新范围元素列表
- AngularJS,在指令的传入内容内分配与更新范围时的不一致's的孤立范围