我需要在图像上添加一个ng-click功能,当我点击它时,它必须增加大小,当我离开鼠标经过时,回到原来的大小。
使用css我已经创建了这个,并在将鼠标放在图像上时运行良好
.images img{
float: left;
height: 100px;
width: 100px;
}
.images img:hover{
width: 30%;
height: 30%%;
transition: width 2s, height 4s
}在我的html上
<img ng-click="$ctrl.changeSize(img)" ng-src="https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />我不知道我必须在changeSize上写些什么才能改变我点击图片时的大小。
我想使用ng-click事件,如何调用函数changeSize中的CSS值?
谢谢。
发布于 2016-11-24 22:59:03
这个函数需要在你的控制器中。
function toggleSize() {
angular.element(document).find('#img-responsive').css({ 'width': '30%', 'height': '30%' });
}
<img id="img-responsive" ng-click="$scope.toggleSize()" ng-src="https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />发布于 2016-11-24 23:20:36
<img ng-click="$ctrl.toggleSize()" ng-class="{little: $ctrl.littleSize, big: !$ctrl.littleSize}" ng-src="https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />在你的控制器中:
$ctrl.littleSize = true;
$ctrl.toggleSize = function() {
$ctrl.littleSize = !$ctrl.littleSize;
}https://stackoverflow.com/questions/40789323
复制相似问题