gpt4 book ai didi

angularjs - Angular ngAnimate 抛出错误

转载 作者:行者123 更新时间:2023-12-02 19:16:10 28 4
gpt4 key购买 nike

我正在尝试使用 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>

这是我的 Controller

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

提前致谢。

最佳答案

解决了!!

将我的 Angular 版本更新为与 Angular 动画版本相同的版本解决了该问题。

关于angularjs - Angular ngAnimate 抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27461986/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com