我正在尝试用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); }; })
提前致谢。
解决了 !!
原文链接:https://www.f2er.com/angularjs/144297.html将我的角度版本更新为等于角动画版本的角度版本修复了问题。