我正在尝试从角度站点工作中获取基本示例动画。我复制粘贴代码,但它不起作用。
我下载了 angular-animate.js(与我的 angular.js 文件 1.2.15 相同的版本)我将它链接到我的代码。我制作了一个 animations.css 文件并将其链接到我的代码(它可以工作,因为当我单击复选框时应用了样式,只是没有动画)
比我从网站上复制粘贴代码
这是我的代码 index.html:
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>My AngularJS App</title>
<link rel="stylesheet" href="css/app.css"/>
<link rel="stylesheet" href="css/animations.css"/>
</head>
<body>
<ul class="menu">
<li><a href="#/login">login</a></li>
<li><a href="#/view2">view2</a></li>
</ul>
<div ng-view></div>
<!--
<div>Angular seed app: v<span app-version></span></div>
-->
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular/angular-animate.js"></script>
<script src="../bower_components/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
</body>
</html>
登录.html
<link rel="stylesheet" href="css/login.css"/>
<div id="loginBox">
<input ng-model="primaryInput" placeholder="Username" type="text" />
<input ng-model="password" placeholder="Password" type="password" />
<input ng-model="email" placeholder="Email" class="check-element animate-show" ng-show="checked" type="text" />
<input ng-model="checked" type="checkbox" /> <span ng-click="checked=!checked" class="checkboxLabel"> Create New Account</span>
<input ng-click="login(primaryInput, password, email)" type="button" value="Login"/>
</div>
<div ng-init="checked=true">
<label>
<input type="checkbox" ng-model="checked" style="float:left; margin-right:10px;"> Is Visible...
</label>
<div class="check-element sample-show-hide" ng-show="checked" style="clear:both;">
Visible...
</div>
</div>
Animations.css:(与网站上的相同)
/*css animations for angularjs*/
.sample-show-hide {
padding:10px;
border:1px solid black;
background:white;
}
.sample-show-hide.ng-hide-add, .sample-show-hide.ng-hide-remove {
-webkit-transition:all linear 0.5s;
-moz-transition:all linear 0.5s;
-o-transition:all linear 0.5s;
transition:all linear 0.5s;
display:block!important;
}
.sample-show-hide.ng-hide-add.ng-hide-add-active,
.sample-show-hide.ng-hide-remove {
opacity:0;
}
.sample-show-hide.ng-hide-add,
.sample-show-hide.ng-hide-remove.ng-hide-remove-active {
opacity:1;
}
login.css:(以防万一)
#loginBox {
position:relative;
clear:both;
display:table;
margin:0 auto;
padding:10px;
padding-top:0px;
border:solid 1px grey;
-moz-border-radius: 4px; /*for older mozila browsers*/
border-radius: 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.07) inset, 0 0 20px rgba(33, 93, 253, 0.5);
}
input[type="password"],
input[type="text"]{
height:15px;
margin-top: 12px;
}
input[type=checkbox]
{
border-radius:4px;
}
.checkboxLabel{
float:left;
font-size:11px;
margin-top:3px;
cursor:pointer;
}
.checkboxLabel:hover {
text-shadow: rgb(46,163,207) 1px 0px 5px;
}
/*TODO animate placeholder so it starts out as black fades out to gray, than possibly fades while start typing*/
input{ /*TODO possibly place in its own class*/
position:relative;
float:left;
clear:left;
/*common for all inputs*/
font-family: "Times New Roman", Times, serif;
border: 1px solid #CCC;
-moz-border-radius: 2px; /*for older mozila browsers*/
border-radius: 2px;
background:white; /*For: chrome*/
}
input:hover{
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.07) inset, 0 0 3px rgba(33, 93, 253, 0.6);
}
input:active {
border: 1px solid #57B5D5;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.07) inset, 0 0 7px rgba(33, 50, 253, 0.6);
}
input:focus {
border: 1px solid #A5BDFE;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.07) inset, 0 0 15px rgba(33, 93, 253, 0.6);
}
[type=button]:hover{
cursor:pointer;
}
[type="button"]::-moz-focus-inner {
border: 0;
}
input { outline: none; } //chrome safari
应用程序.js:
'use strict';
// Declare app level module which depends on filters, and services
angular.module('myApp', [
'ngRoute',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/login', {templateUrl: 'partials/login.html', controller: 'LoginCtrl'});
$routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'});
$routeProvider.otherwise({redirectTo: '/login'});
}]);