【问题标题】:AngularJS Error: Unknown provider: $animateProvider <- $animateAngularJS 错误:未知提供者:$animateProvider <- $animate
【发布时间】:2023-03-27 23:30:01
【问题描述】:

未捕获错误:[$injector:unpr] 未知提供者:$animateProvider

我正在尝试使用此链接中给出的 Angular-ui 创建一个轮播。 http://angular-ui.github.io/bootstrap/

但是,我得到了那个错误。

详细信息:我正在使用 .min 角度脚本文件。 index.html 的代码与链接中给出的代码相同。 根据这篇文章Error: Unknown provider: employeesProvider <- employees,我从 html 中获取了 ng-controller,并将控制器绑定到了 angular-seed 应用程序中给出的 controller.js 中。

另外,http://docs.angularjs.org/error/$injector:unpr?p0=$animateProvider%20%3C-%20$animate 没有帮助我。

可能是什么原因?

【问题讨论】:

标签: angularjs angular-ui


【解决方案1】:

我也遇到了和你一样的问题,我使用 angular-1.4.3 版本解决了这个问题,这是我解决问题的过程。 当我尝试运行演示时,我试图从网络demo adress 运行指令“nginclude”,像你一样在 Firefox 控制台中弹出错误,但是当我将版本更改为 Angular 的 1.4.3 时,它都解决了。 顺便说一下,你可以从1.4.3下载版本

.js
var APP = angular.module('app', ['ngAnimate'])
APP.controller('ctrl', ['$scope', function($scope) {
$scope.templates =
  [{name: 'template1.html',url:'template1.html'},
    {name: 'template2.html',url:'template2.html'}];
$scope.template = $scope.templates[0];}]);
.html
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta Content-Type="html/text;charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/animation.css">
<title>ngInclude demo</title>
</head>
<body>
<div ng-controller="ctrl">
  <select ng-model="template" ng-options="t.name for t in templates">
     <option value="">(blank)</option>
  </select>
     url of the template: <code>{{template.url}}</code>
  <hr/>
  <div class="slide-animate-container">
  <div class="slide-animate" ng-include="template.url"></div>
 </div>
 </div>
 </body>
<script src="js/angular.js"></script>
<script src="js/ngInclude.js"></script>
<script src="js/angular-animate.js"></script>
</html>

谢谢。

【讨论】:

  • 您应该将相关代码添加到您的答案中,而不仅仅是链接到外部链接
  • 嗨singe3,谢谢你的提醒,我自己是新来的。
【解决方案2】:

此错误也可能由于 Chrome 中的 Batarang 自动更新而发生。我使用旧版本 Angular 的网站突然开始给我这个错误(未知提供者:$animateProvider

【讨论】:

    【解决方案3】:

    当我将 ngAnimate 引入使用旧版本 Angular 的项目时,我也遇到了 Unknown Provider 问题。最好的办法是在项目中使用与当前 Angular 版本相同的 ngAnimate 版本。它们似乎是同时发布的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-21
      • 2013-01-25
      • 2014-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多