如何在{{scope}}
中调试一个小胡子变量ng-init
以从视图调试双向绑定/作用域?
HTML:
<div ng-init="omg({{svglayout(key).width}})"></div>
JS:
$scope.omg = function(evt) {
console.log(evt);
};
我知道有很多其他方法可以做到这一点,但我试图确保数据在标记中得到适当的范围,并且它不是导航错误......
通过使用console.log,我可以更容易地测试标记,因为有很多固定的位置元素。
更新
如果我删除插值没有抛出错误但它出现undefined
对象不是未定义的,因为我知道如果我去
<p style="position: absolute; z-index: 99999; top:0; left:0; height: 500px; width: 500px background: #fff;">{{svglayout(key)}}</p>
这有结果:
{"width":707.912457912458}
和svglayout函数:
scope.svglayout = function(idx) {
var newWidth = (scope.windowHeight-clearanceSetter)* (scope.adPageData.pages[idx].imagewidth/scope.adPageData.pages[idx].imageheight);
return {
width: newWidth
}
};
答案 0 :(得分:0)
尝试删除字符串插值
omg(svglayout(key).width)