我正在使用 angularjs,并且每次更改模型属性时都尝试触发动画。我的控制器:
function myCtrl($scope) {
$scope.data.counter = 0;
$scope.addCount = function() {
$scope.data.counter ++;
};
}
我的html:
<div ng-controller="myCtrl">
<button ng-click="addCount()">add count</button>
<div class="bgimage"></div>
</div>
我的CSS:
.bgimage {
background-image: url('../images/a.png');
background-position: right;
background-size: 16px 14px;
width: 16px;
height: 14px;
}
.bgimage.pulse {
-webkit-animation: pulse 1s both;
-moz-animation: pulse 1s both;
-o-animation: pulse 1s both;
animation: pulse 1s both;
}
我希望每次“计数”发生变化时,“bgimage”元素都会被“脉冲”。
任何想法?