Angular ngAnimate会抛出错误

时间:2014-12-13 18:01:53

标签: angularjs ng-animate

我正在尝试使用ngAnimate做一些动画,但我甚至无法开始使用它。问题是,当我尝试将ngAnimate依赖项添加到app文件时,它会在控制台中抛出此错误,而我的应用程序无效。

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);
    };
})

提前致谢。

1 个答案:

答案 0 :(得分:28)

解决了!!

将我的角度版本更新为等于角度动画版本的版本可以解决问题。