Javascript 在angular中,为什么我的ng显示没有更新以反映当前范围?
我有一个ng节目,在一个ng重复中,在另一个ng重复中。那场ng秀里面有一个按钮。当我单击按钮时,我的作用域已正确更新,但ng显示在我刷新页面之前不会更改 模板:Javascript 在angular中,为什么我的ng显示没有更新以反映当前范围?,javascript,angularjs,angularjs-scope,ng-repeat,ng-show,Javascript,Angularjs,Angularjs Scope,Ng Repeat,Ng Show,我有一个ng节目,在一个ng重复中,在另一个ng重复中。那场ng秀里面有一个按钮。当我单击按钮时,我的作用域已正确更新,但ng显示在我刷新页面之前不会更改 模板: <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._step
<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.quests的console.log显示了一个正确更新的任务对象(我真的不明白,因为我正在增加currentQuest.progress,而不是$scope.quests[$index]或其他什么,但是由于范围已经更新,我不在乎),那么,究竟为什么不显示和隐藏正确的ng显示呢???因为您使用的是内插大括号
{}
ng show
直接读取表达式。许多核心指令也是如此
插值大括号用于将文本打印到dom中
改变
ng-show="{{quest.progress === 0}}"
到
因为您使用的是内插大括号
{{}
ng show
直接读取表达式。许多核心指令也是如此
插值大括号用于将文本打印到dom中
改变
ng-show="{{quest.progress === 0}}"
到
调试的一个好主意可能是在模板内输出quest.progress和step.order的值。调试的一个好主意可能是在模板内输出quest.progress和step.order的值。
ng-show="quest.progress === 0"