【发布时间】:2014-10-02 01:22:38
【问题描述】:
我有一个网站,其中有多个按钮。按下按钮后,我会填充一个列表,尽管我的问题是最后按下的按钮一直处于按下状态(具有 :active 类)。我考虑过使用 Angular 的 $timeout 来重置按钮,尽管 removeClass 函数不能解决问题。
我的观点是这样的:
div(ng-controller='productButtonController')
div(ng-repeat='product in products')
div.col-md-4
button.btn.btn-block.sell-button(id='{{product._id}}' ng-click='sell()'){{product.name}}
和我的控制器:
app.controller('productButtonController', ['$scope', '$timeout', 'productServices', 'flash',
function($scope, $timeout, productServices, flash) {
productServices.getProducts()
.success(function(result) {
$scope.products = result.data
})
.error(showErrorMessage(flash))
$scope.sell = function() {
console.log(this.product)
that = this
$('#' + that.product._id).removeClass('active')
}
}
])
【问题讨论】:
-
按钮的代码是什么样的?我遇到了一个问题,我使用引导切换同时更改外观和角度样式条件,这导致按钮被双重切换,因此无法正确显示。
-
所以向我们展示你的 js/html 代码。如果可能的话,重现这个小提琴。
标签: angularjs twitter-bootstrap