【发布时间】:2018-04-18 20:09:16
【问题描述】:
我已经绑定到看起来像这样的函数:
function func() {
this.scopeVar = {
bla: this.isolateScopeVar.bla,
gla: this.isolateScopeVar.gla
}
}
我有这个 html 代码:
<span>{{this.scopeVar.bla}}</span>
<span>{{this.scopeVar.gla}}</span>
我的问题是,如果 this.isolateScopeVar.bla 或 this.isolateScopeVar.gla 已更改,span 不会在没有任何 func 触发的情况下更新。
我可以使用这个可行的方法:
function func() {
return {
bla: this.isolateScopeVar.bla,
gla: this.isolateScopeVar.gla
}
}
<span>{{this.func().bla}}</span>
<span>{{this.func().gla}}</span>
但我认为这不是最好的方法。
还有其他正确的方法吗?
【问题讨论】:
-
为什么要通过一个函数来获取这些值?
this.isolateScopeVar.bla不工作? -
^ 或者如果你有
this.使用什么语法?
标签: javascript html angularjs data-binding