1
我試圖對指令應用簡單的不透明度轉換,但它沒有做任何事情。下面是代碼:如何應用ng-enter angularjs動畫
WelcomeDirective.js
(function() {
"use strict";
angular.module("myModule")
.directive("wamWelcome", Welcome);
Welcome.$inject = ["$animate"];
function Welcome($animate) {
return {
restrict: "E",
templateUrl: "shared/directives/welcomeMessage/WelcomeTemplate.html",
link: function(scope, element, attrs) {
$animate.addClass(element, "welcome");
}
};
}
})();
WelcomeTemplate.js
/* Animations */
/* Add animation */
.welcome.ng-enter {
opacity: 1;
-webkit-transition: opacity 300ms linear;
transition: opacity 300ms linear;
}
/* Remove animation */
.welcome.ng-leave {
opacity: 0;
-webkit-transition: opacity 300ms linear;
transition: opacity 300ms linear;
}
</style>
<div id="welcome-panel" class="alert alert-info alert-dismissible" role="alert" ng-if="profile.welcome">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<strong>Welcome</strong>
</div>
如果I'm正確認識它,當模板進入,角應適用的動畫。
你已經包含了ngAnimate模塊? 'angular.module('myModule',['ngAnimate']' – devqon
是的,它包括 –