我想要的是,当orderHistory.type(初始值为“list”的作用域变量)的值更改为“show”时,< Strong>showOrder.html 模板已呈现。更新 orderHistory.type 的函数是通过单击 orderHistoryList.html 中的链接来调用的。 模型正在更新,但模板没有改变。已经谢谢了。
<div data-ng-controller="SettingsController">
<div ng-if="orderHistory.type=='list'" data-ng-include="'orderHistoryList.html'"></div>
<div ng-if="orderHistory.type=='show'"data-ng-include="'showOrder.html'"></div>
最佳答案
明白了,我在 orderHistoryList.html 中设置属性 ng-controller 时也犯了一个错误,这在两个页面上创建了不同的 SettingsController 实例。因此,当模型在其中一个实例中更新时,它在主页上没有显示任何更改。
关于javascript - 当范围变量更新时如何更新模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34019140/