[英]Angular view template content updates only on mouse over
I have a strange behavior using an Angular template with a controller . 使用带有控制器的Angular模板时,我有一个奇怪的行为。 A special view content often updates on mouse over only.
特殊视图内容通常仅在鼠标悬停时更新。 I have setup a few jsFiddles but cannot reproduce the problem.
我已经设置了一些jsFiddles,但是无法重现该问题。 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. 我在这里看到的唯一特别的事情是,我使用
$scope
方法来格式化和显示HTML内容。 {{order.total()}} €
It is weird that it work sometimes. {{order.total()}} €
有时很奇怪。
All other HTML parts are updating as expected. 其他所有HTML部分均按预期更新。 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 可能没有理由您的表情不起作用,所以我会
What is the library behind ? 背后的图书馆是什么?
Mock Globalize function 模拟全球化功能
var Globalize = {
format : function(a,b) {
return 22;
}
};
http://jsfiddle.net/darul75/5L2d9y75/ http://jsfiddle.net/darul75/5L2d9y75/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.