"未捕获的错误:[$喷油器:unpr] QUOT;与部署后角 [英] "Uncaught Error: [$injector:unpr]" with angular after deployment

查看:143
本文介绍了"未捕获的错误:[$喷油器:unpr] QUOT;与部署后角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行我的dev的机器就好了,但与此错误消息失败(在浏览器控制台)后,我部署一个相当简单的角度应用程序:

I have a fairly simple Angular application that runs just fine on my dev machine, but is failing with this error message (in the browser console) after I deploy it:

未捕获的错误:[$喷油器:unpr] http://errors.angularjs.org/undefined/$injector/unpr?p0=tProvider%20%3C-%20t%20%3C-%20%24http%20%3C-%20%24compile

除此之外没有其他消息。它发生在当页面首次加载。

No other message besides that. It happens when the page first loads.

我运行ASP.NET MVC5,角1.2RC3,推动通过混帐到Azure。

I'm running ASP.NET MVC5, Angular 1.2RC3, and pushing to Azure via git.

谷歌搜索并没有止跌回升什么有趣的事。

Googling hasn't turned up anything interesting.

有什么建议?

编辑:

我使用的是打字稿,并建立与该 $注变量,例如我的依赖关系:

I'm using TypeScript, and defining my dependencies with the $inject variable, e.g.:

export class DashboardCtrl {

    public static $inject = [
        '$scope',
        '$location',
        'dashboardStorage'
    ];

    constructor(
        private $scope: IDashboardScope,
        private $location: ng.ILocationService,
        private storage: IDashboardStorage) {
    }
}

我认为应该(或拟)周围的缩小过程中出现的,而且可能会导致这个错误的局部变量改名的问题搞定。

I believe that should (or is intended to) get around the local variable renaming problems that arise during minification and that can cause this error.

这就是说,它显然有事情做与缩小过程,因为当我设置 BundleTable.EnableOptimizations = TRUE 我的dev的机器上,我可以重现它。

That said, it clearly has something to do with the minification process, as when I set BundleTable.EnableOptimizations = true on my dev machine, I can reproduce it.

推荐答案

如果您按照您的链接,它会告诉你从$喷油器错误的结果不能够解决您的依赖关系。这是当棱角分明的JavaScript被缩小的/变丑/你在做它生产的任何一个常见的​​问题。

If you follow your link, it tells you that the error results from the $injector not being able to resolve your dependencies. This is a common issue with angular when the javascript gets minified/uglified/whatever you're doing to it for production.

问题是,当你有例如控制器;

The issue is when you have e.g. a controller;

angular.module("MyApp").controller("MyCtrl", function($scope, $q) {
  // your code
})

的微小变化 $范围 $ Q 为随机变量不告诉角度注入什么。解决的办法是声明你的依赖关系是这样的:

The minification changes $scope and $q into random variables that doesn't tell angular what to inject. The solution is to declare your dependencies like this:

angular.module("MyApp")
  .controller("MyCtrl", ["$scope", "$q", function($scope, $q) {
  // your code
}])

这应该解决您的问题。

只是再次重申,一切我说的是错误信息提供给您的链接。

Just to re-iterate, everything I've said is at the link the error message provides to you.

这篇关于"未捕获的错误:[$喷油器:unpr] QUOT;与部署后角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆