简体   繁体   English

Angular JS动画不起作用

[英]Angular JS Animation Not Working

I'm trying to show/hide a details field in angular js. 我正在尝试在angular js中显示/隐藏详细信息字段。 The details show and hide, but there is no animation for some reason. 显示和隐藏细节,但是由于某些原因没有动画。

<div class="directoryEntry" ng-repeat="listing in listings">
        <span class="category">{{listing.category}}</span>
                    ...
        <a ng-click="sElement = $index" href="javascript:void(0)">Member Details ></a>
        <div ng-show="$index == sElement" ng-animate="{show: 'details-show', hide: 'details-hide'}">{{listing.details}}</div>
    </div>

This is the CSS: 这是CSS:

.details-show, .details-hide {
-webkit-transition:all linear 0.5s;
-moz-transition:all linear 0.5s;
-ms-transition:all linear 0.5s;
-o-transition:all linear 0.5s;
transition:all linear 0.5s;
}

.details-show.details-show-active,
.details-hide {
opacity:1;
}

.details-hide.details-hide-active,
.details-show {
opacity:0;
}

First make sure you include the ngAnimation module inside your application. 首先,请确保在应用程序中包含ngAnimation模块。 You should add the correct script in your HTML and require it in your application module declaration like this: 您应该在HTML中添加正确的脚本 ,并在您的应用程序模块声明中要求它,如下所示:

angular.module('yourApp', ['ngAnimate']);

You should also use the .ng-hide-add and .ng-hide-remove for your animations. 您还应该为动画使用.ng-hide-add.ng-hide-remove To get more information, you can consult this example in the AngularJS documentation: https://docs.angularjs.org/api/ng/directive/ngShow#usage_animations 要获取更多信息,您可以在AngularJS文档中查询以下示例: https ://docs.angularjs.org/api/ng/directive/ngShow#usage_animations

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM