occassional未知提供者:$ templateRequestProvider

时间:2021-07-23 10:48:19

I'm working on an angular app, and it works completely fine on computer#1, and when I've cloned the git repo on computer#2 and performed my npm install, bower install, and grunt bower-install, things fail to load.

我正在研究一个有角度的应用程序,它在计算机#1上完全正常工作,当我在计算机#2上克隆git repo并执行我的npm安装,bower安装和grunt bower-install时,事情就失败了加载。

After googling around, many have cited that this is a common side effect of ng-route not being included.

在谷歌上搜索之后,许多人都指出这是ng-route的常见副作用,不包括在内。

Upon page load, 'view source' appears to show that ng-route was successfully included:

页面加载后,“查看源”似乎显示ng-route已成功包含:

<!-- build:js(app) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/Chart.js/Chart.js"></script>
<script src="bower_components/angular-chart.js/dist/angular-chart.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/d3/d3.js"></script>
<script src="bower_components/codemirror/lib/codemirror.js"></script>
<script src="bower_components/angular-ui-codemirror/ui-codemirror.js"></script>
<!-- endbower -->
<!-- endbuild -->

And my app.js file definitely is asking for ngRoute:

我的app.js文件肯定要求ngRoute:

angular.module('myApp', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ngRoute',
  'chart.js',
  'ui.bootstrap',
  'ui.codemirror'
])

and my routes are defined this way:

我的路线是这样定义的:

$routeProvider.when('/dashboard', {
  templateUrl: 'partials/dashboard',
  controller: 'DashboardCtrl'
})

Then I've checked that those dependencies have in fact loaded:

然后我检查了那些依赖项实际上已加载:

occassional未知提供者:$ templateRequestProvider

^-- which appears to be "yes" they have loaded. I've clicked through them to make sure the responses are actually the correct javascript content. Each contains the correct content.

^ - 他们加载似乎是“是”。我点击了它们以确保回复实际上是正确的javascript内容。每个都包含正确的内容。

In terms of version of the angular-route.js resource,

就angular-route.js资源的版本而言,

  • the working site uses route v1.3.14
  • 工作地点使用路线v1.3.14

  • the not-working site uses route v1.3.15
  • 非工作站点使用路由v1.3.15

The error message in the console doesn't appear to have anything useful in it in terms of identifying why this is happening. How do I debug this?

控件中的错误消息似乎没有任何有用的内容,无法确定发生这种情况的原因。我该如何调试?

2 个解决方案

#1


Even though your answer got solved I got similar issue now,

即使你的答案得到解决,我现在遇到了类似的问题,

I got this issue because I have different versions of angular.min.js and angular-route.js

我遇到了这个问题因为我有不同版本的angular.min.js和angular-route.js

I have used 1.2.0 of Angular and 1.3.5 of angular-route.js and that caused the same error.

我使用了1.2.0的Angular和1.3.5的angular-route.js,这导致了同样的错误。

#2


Have you checked if you properly have the following components into your bower dir ?

你有没有检查过你的凉亭目录中是否有以下组件?

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>

Or if you have any HTML issue into Network regarding the downloading of the package ?

或者,如果您有关于下载程序包的任何HTML问题进入网络?

Your error looks like the ngRoute module is not loaded and when trying to use the provider, generates this issue.

您的错误似乎未加载ngRoute模块,并且在尝试使用提供程序时,会生成此问题。

#1


Even though your answer got solved I got similar issue now,

即使你的答案得到解决,我现在遇到了类似的问题,

I got this issue because I have different versions of angular.min.js and angular-route.js

我遇到了这个问题因为我有不同版本的angular.min.js和angular-route.js

I have used 1.2.0 of Angular and 1.3.5 of angular-route.js and that caused the same error.

我使用了1.2.0的Angular和1.3.5的angular-route.js,这导致了同样的错误。

#2


Have you checked if you properly have the following components into your bower dir ?

你有没有检查过你的凉亭目录中是否有以下组件?

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>

Or if you have any HTML issue into Network regarding the downloading of the package ?

或者,如果您有关于下载程序包的任何HTML问题进入网络?

Your error looks like the ngRoute module is not loaded and when trying to use the provider, generates this issue.

您的错误似乎未加载ngRoute模块,并且在尝试使用提供程序时,会生成此问题。