我想在某些情況下在元素上啓用和禁用懸停狀態。非常新的角度,所以不知道如何接近它。也沒有在網上找到解決方案。在AngularJS中禁用並啓用懸停
假CSS代碼:
xyz{
background:#2f9bdb;
}
xyz:hover{
background:#d7d7d7;
}
HTML:
<button ng-click="toggleEnable()"></button>
<div class="xyz" on-hover-select></div>
NG-應用和NG-模塊來完成。我的JS:
angular.module('myModule',[])
.controller('myCtrl',function($scope){
$scope.enableHover=true;
$scope.toggleEnable=function(){
return $scope.enableHover=!$scope.enableHover;
}
}).directive('onHoverSelect',function(){
return{
restrict:'A',
link:function(scope,ele,attrs){
if(scope.enableHover){
//enable hover
}else{
//disable hover
}
}
}
});
我已經試過對角元件使用綁定解除綁定,但它不工作。也將指令更新本身enableHover值更改?可能是基本的,但對框架來說很新。請幫助