我想创建一个简单的切换按钮,当按下,悬停和未按下(常规模式)时,该按钮具有我选择的特定图像。就那么简单。 我找不到......
由于
答案 0 :(得分:1)
我做了一个简单的指令,它可能会帮助你获得一种感觉
controller: function($scope) {
$scope.clicked = false;
$scope.entered = false;
$scope.imageUrl = $scope.defaultImg;
$scope.click = function() {
$scope.entered = false;
$scope.clicked = !$scope.clicked;
checkStates();
}
$scope.hover = function(val) {
$scope.entered = val;
checkStates();
}
function checkStates() {
if ($scope.entered) {
$scope.imageUrl = $scope.hoveredImg;
} else {
if ($scope.clicked) {
$scope.imageUrl = $scope.pressedImg;
} else {
$scope.imageUrl = $scope.defaultImg;
}
}
}