我正在尝试使用ngAnimate做一些动画,但是我什至无法开始。问题是,当我尝试将ngAnimate依赖项添加到应用程序文件时,它将在控制台中引发此错误,并且我的应用程序无法正常工作。
Uncaught Error: [$injector:unpr] Unknown provider: $$jqLiteProvider <- $$jqLite <- $animate <- $compile
http://errors.angularjs.org/1.3.5/$injector/unpr?p0=%24%24jqLiteProvider%20%3C-%20%24%24jqLite%20%3C-%20%24animate%20%3C-%20%24compileangular.js:63 (anonymous function)angular.js:3950 (anonymous function)angular.js:4097 getServiceangular.js:3955 (anonymous function)angular.js:4097 getServiceangular.js:4129 invokeangular.js:4025 origProvider.$getangular.js:4138 invokeangular.js:3956 (anonymous function)angular.js:4097 getServiceangular.js:4129 invokeangular.js:3956 (anonymous function)angular.js:4097 getServiceangular.js:4129 invokeangular.js:1435 doBootstrapangular.js:1455 bootstrapangular.js:1349 angularInitangular.js:25912 (anonymous function)angular.js:2722 triggerangular.js:2992 eventHandler
但是没有添加ngAnimate依赖关系就可以正常工作。不知道我在做什么错。
这是我的app.js
var app = angular.module('myApp', ['ngRoute','ngAnimate']);
app.config(function($routeProvider) {
$routeProvider
.when('/home', {
controller: 'homeCtrl',
templateUrl: '/partials/home.html'
})
.when('/register', {
controller: 'regCtrl',
templateUrl: '/partials/register.html'
})
.when('/login', {
controller: 'loginCtrl',
templateUrl: '/partials/login.html'
}).when('/', {
redirectTo: '/home'
}).otherwise({
redirectTo: '/register'
});
});
这是我的html
<!DOCTYPE html>
<html>
<head>
<title>Angular Tutorial</title>
</head>
<body ng-app='myApp'>
<div class="container">
<header>
<h1>Logo</h1>
<a href="#/home">Home</a>
<a href="#/register">Register</a>
<a href="#/login">Login</a>
</header>
<ng-view></ng-view>
</div>
<!-- Vendor libraries -->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.min.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<!-- App libraries -->
<script src="app/app.js"></script>
<script src="app/controllers/controllers.js"></script>
</body>
</html>
这是我的控制器
app.controller('homeCtrl', function($scope) {
$scope.message = "Home page"
});
app.controller('regCtrl', function($scope) {
$scope.message = "Registration message";
$scope.register = function() {
alert($scope.fname + "\n" + $scope.lname + "\n" + $scope.email + "\n" + $scope.password);
};
})
app.controller('loginCtrl', function($scope) {
$scope.message = "Login message";
$scope.login = function() {
alert($scope.myemail + "\n" + $scope.password);
};
})
提前致谢。
最佳答案
解决了 !!
将我的角度版本更新为等于角度动画版本的版本即可解决此问题。