Angularjs ng-hide动画不起作用



我尝试了这个plunker的angularjs动画。但是在我的本地,动画不起作用。正常的隐藏/显示工作正常,但不显示动画。

我的代码如下:

索引显示.html

<html>  
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-animate.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
        <script src="./app-show.js"></script>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="./app-show.css">
    </head>
    <body ng-app="myApp1">
        <div id='outerdiv' ng-controller="MyCtrl">
            <div ng-click="myValue=true">LEFT</div>
            <div ng-click="myValue=false">RIGHT</div>
            <div id="one" class='animate-hide' ng-hide="myValue">this is just a sample div</div>{{myValue}}</div>
    </body>
</html>

应用显示.css

.animate-hide {
    -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
    -moz-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
    -o-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
    transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
    line-height:20px;
    opacity:1;
    padding:10px;
    border:1px solid black;
    background:white;
    position: absolute;
    left: 0;
}
.animate-hide.ng-hide {
    left: -100%;
    opacity:0;
    padding:0 10px;
}

应用显示.js

var app = angular.module("myApp1", ["ngAnimate"]);
app.controller("MyCtrl", function ($scope) {
    $scope.myValue=false;
});

请让我知道我错过了什么??

该问题是由您使用的角度版本引起的。在您提供的示例中,版本是角度 1.2.20,而您使用的是 1.2.0-rc.2

升级你的版本角度,你应该发现代码有效。

最新更新