gpt4 book ai didi

javascript - angular ngShow 动画不工作

转载 作者:太空宇宙 更新时间:2023-11-04 16:28:18 25 4
gpt4 key购买 nike

这是来自angularjs的例子

https://docs.angularjs.org/api/ng/directive/ngShow

我把所有的东西都放在我的本地

为什么不能在我的本地工作?

我错过了什么?

<!doctype html>
<html xmlns:ng="http://angularjs.org" ng-app="animateApp">
<head>

跳过样式部分..因为它太长了

  <script src="http://code.angularjs.org/1.2.15/angular.js"></script>
<script src="http://code.angularjs.org/1.2.15/angular-animate.js"></script>
<script>
angular.module('animateApp', ['ngAnimate']);
var thumbsUp = element(by.css('span.glyphicon-thumbs-up'));
var thumbsDown = element(by.css('span.glyphicon-thumbs-down'));

it('should check ng-show / ng-hide', function() {
expect(thumbsUp.isDisplayed()).toBeFalsy();
expect(thumbsDown.isDisplayed()).toBeTruthy();

element(by.model('checked')).click();

expect(thumbsUp.isDisplayed()).toBeTruthy();
expect(thumbsDown.isDisplayed()).toBeFalsy();
});

</script>
</head>
<body>
<h2>Animation - Animate</h2>

Click me: <input type="checkbox" ng-model="checked"><br/>
<div>
Show:
<div class="check-element animate-show" ng-show="checked">
<span class="glyphicon glyphicon-thumbs-up"></span> I show up when your checkbox is checked.
</div>
</div>
<div>
Hide:
<div class="check-element animate-show" ng-hide="checked">
<span class="glyphicon glyphicon-thumbs-down"></span> I hide when your checkbox is checked.
</div>
</div>

          .animate-show {
line-height:20px;
opacity:1;
padding:10px;
border:1px solid black;
background:white;
}

.animate-show.ng-hide-add,
.animate-show.ng-hide-remove {
display:block!important;
}

.animate-show.ng-hide-add.ng-hide-add-active,
.animate-show.ng-hide-remove.ng-hide-remove-active {
-webkit-transition:all linear 0.5s;
transition:all linear 0.5s;
}

.animate-show.ng-hide {
line-height:0;
opacity:0;
padding:0 10px;
}

.check-element {
padding:10px;
border:1px solid black;
background:white;
}

最佳答案

根据我从您提供的代码中收集到的信息;这就是您要找的...

working jsFiddle

注意:我更改了一些 CSS 以使淡出有效。我也不知道什么对你不起作用。你的问题提到了 ng-show 动画,但我没有看到任何代码试图在节目中制作动画。当我将您的代码放入 jsFiddle 时,复选框不起作用,而且 ng-hide 上也没有动画。两者现在都在 jsFiddle 中工作。那是你要找的吗?如果没有,让我们解决这个问题。

var app = angular.module('myApp', ['ngAnimate']);

app.controller('MyCtrl', function ($scope) {});

HTML...

<div ng-app="myApp">
<div ng-controller="MyCtrl">
<body>
<h2>Animation - Animate</h2>
Click me:
<input type="checkbox" ng-model="checked">
<br/>
<div>Show:
<div class="check-element animate-show" ng-show="checked">
<span class="glyphicon glyphicon-thumbs-up"></span>
I show up when your checkbox is checked.</div>
</div>
<div>
Hide:
<div class="check-element animate-show" ng-hide="checked">
<span class="glyphicon glyphicon-thumbs-down"></span>
I hide when your checkbox is checked.</div>
</div>
</div>
</div>
</body>
</div>
</div>

CSS...

.animate-show {
line-height:20px;
opacity:1;
padding:10px;
border:1px solid black;
background:white;
}

.animate-show.ng-hide-add, .animate-show.ng-hide-remove {
display:block!important;
}

.animate-show.ng-hide-add {
-webkit-transition:all linear 0.5s;
transition:all linear 0.5s;
}

.animate-show.ng-hide {
line-height:0;
opacity:0;
padding:0 10px;
}

.check-element {
padding:10px;
border:1px solid black;
background:white;
}

关于javascript - angular ngShow 动画不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23705937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com