角视图模板的内容只在鼠标悬停更新 [英] Angular view template content updates only on mouse over
问题描述
我在使用与控制器的角度模板的奇怪的行为。一个特殊的视图内容往往比只更新鼠标。我已经建立了几个jsFiddles但无法重现该问题。因此,它显然是在我的源$ C $ C是错误的。我在这里看到的唯一特殊的是,我用的是 $范围
法格式化和显示HTML内容。 {{order.total()}}€
这是奇怪的,它有时工作。
所有其它HTML部分更新预期。任何想法可能是错误的?
$ scope.order = {\r
_Total:0,\r
总:功能(){\r
返回Globalize.format(this._total中,n);\r
},\r
的位置:[]\r
};\r
\r
\r
$ scope.addProductToCurrentOrder =功能(packageIndex,productId参数){\r
\r
VAR RS = {\r
_id:productId参数\r
};\r
\r
\r
VAR选项卡= $ scope.categories [packageIndex] .packages;\r
对于(VAR I = 0; I< tab.length;我++){\r
VAR包=标签[I];\r
如果(pack.productId === productId参数){\r
pack.quantity ++;\r
rs.articleName = pack.name;\r
rs.price = pack.price;\r
rs._price = pack._price;\r
rs.unit = pack.unit;\r
rs.weight = pack.weight;\r
打破;\r
}\r
}\r
$ scope.order.positions.push(RS);\r
$ scope.order._total + = rs._price;\r
};
\r
< H1>\r
<跨度类=BTN BTN-默认BTN-大的> {{order.total()}}€< / SPAN>\r
< / H1>\r
\r
< DIV数据-ID ={{package.productId}}级=BTN BT默认面板面板默认顺序顺序卡withrippleNG点击=addProductToCurrentOrder($父$指数,package.productId。) >\r
< DIV CLASS =面板体>\r
< p =班领导> {{package.name}}&下; / P>\r
&所述p为H.; {{package.weight}} {{package.unit}}&下; / P>\r
< / DIV>\r
< DIV CLASS =波纹包装>< / DIV>\r
< / DIV>
\r
有可能是没有理由你的前任pression不工作,这样反而我会
- 全球化时代删除函数调用,然后看看是怎么回事与国际化。
- 计算重新计算新的总时全球化的字符串。
- 使用过滤器()角前pression计算的全球化。
什么是图书馆的后面?
全球化时代模拟功能
全球化时代VAR {=
格式:功能(A,B){
返回22;
}
};
http://jsfiddle.net/darul75/5L2d9y75/
I have a strange behavior using an Angular template with a controller . A special view content often updates on mouse over only. I have setup a few jsFiddles but cannot reproduce the problem. So it is obviously a mistake in my source code. The only special thing I see here is that I use a $scope
method to format and display HTML content. {{order.total()}} €
It is weird that it work sometimes.
All other HTML parts are updating as expected. Any idea what could be wrong?
$scope.order = {
_total : 0,
total : function() {
return Globalize.format(this._total, "n");
},
positions: []
};
$scope.addProductToCurrentOrder = function(packageIndex, productId) {
var rs = {
_id : productId
};
var tab = $scope.categories[packageIndex].packages;
for (var i = 0; i < tab.length; i++) {
var pack = tab[i];
if (pack.productId === productId){
pack.quantity++;
rs.articleName = pack.name;
rs.price = pack.price;
rs._price = pack._price;
rs.unit = pack.unit;
rs.weight = pack.weight;
break;
}
}
$scope.order.positions.push(rs);
$scope.order._total += rs._price;
};
<h1>
<span class="btn btn-default btn-large">{{order.total()}} €</span>
</h1>
<div data-id="{{package.productId}}" class="btn bt-default panel panel-default order order-card withripple" ng-click="addProductToCurrentOrder($parent.$index, package.productId)">
<div class="panel-body">
<p class="lead"> {{package.name}}</p>
<p>{{package.weight}} {{package.unit}}</p>
</div>
<div class="ripple-wrapper"></div>
</div>
there might be no reason your expression not be working, so instead I will
- remove Globalize function call, then see what is going on with Globalize.
- compute globalize string when recomputing new Total.
- use of filter() angular expression to compute globalization.
What is the library behind ?
Mock Globalize function
var Globalize = {
format : function(a,b) {
return 22;
}
};
http://jsfiddle.net/darul75/5L2d9y75/
这篇关于角视图模板的内容只在鼠标悬停更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!