Angularjs $injector:unpr 在缩小后的运行方法中
Angularjs $injector:unpr in the run method after minification
我在我的Angular应用程序上使用Angular-xeditable。它在开发环境中工作正常,但在生产环境中,当所有 js 文件都缩小时,我收到此错误:
Uncaught Error: [$injector:strictdi] http://errors.angularjs.org/1.3.5/$injector/strictdi?p0=function(n)
搜索我的代码,我发现可编辑有问题。这里是咖啡脚本中的应用程序创建代码:
# create the angular app
angular.module 'dbManagerApp', ['xeditable', 'ngDraggable']
# set the theme for the xeditable
.run (editableOptions, editableThemes) ->
# set the default theme
editableOptions.theme = 'default'
# override the ok button
editableThemes['default'].submitTpl = '<div class="small primary btn"><input type="submit" value="Ok" /></div>'
# override the cancel button
editableThemes['default'].cancelTpl = '<div class="small warning btn" ng-click="$form.$cancel()"><a href="#">Cancel</a></div>'
这里是缩小版本:
(function(){angular.module("dbManagerApp",["xeditable","ngDraggable"]).run(function(n,t){if(!_.isUndefined(n||_.isUndefined(n.theme)))return n.theme="default",t["default"].submitTpl='<div class="small primary btn"><input type="submit" value="Ok" /><'/div>',t["default"].cancelTpl='<div class="small warning btn" ng-click="$form.$cancel()"><a href="#">Cancel<'/a><'/div>'})}).call(this);
//# sourceMappingURL=DbManagerApp.min.js.map
如果我在 run 方法中注释代码,它不会引发异常。此方法用于配置可编辑对象,如文档中所述。我无法弄清楚这种奇怪的行为,有没有办法查看可编辑项是否成功添加到角度应用程序中,或者是否有其他内容需要检查?
您必须注入依赖项:
.run ( ['editableOptions', 'editableThemes', function(editableOptions, editableThemes)
与控制器、服务等类似(请记住在运行)
之前添加]
。
这是因为最小化器(如 uglify)更改变量名称。按照上述方式,缩小的代码将是:
.run( ['editableOptions', 'editableThemes', function(n,t){
n
和t
将是对这些依赖项的引用。
相关文章:
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- PhantomJS - 检查javascript函数是否正在运行的任何方法
- 实现比较方法的最佳实践是什么;s的比较类型是在运行时选择的
- Meteor应用程序无法运行-对象#<编译器>没有方法'主机'
- 使用c#在Web服务器上运行JavaScript方法
- strongloop script.js run find in before delete方法:如何同步运行异步方法
- jQuery 在运行 C# 方法时重置
- 在浏览器关闭选项卡或浏览器退出上运行方法
- jQuery 运行 C# 方法
- Angularjs $injector:unpr 在缩小后的运行方法中
- 检查隐藏的布尔值以运行方法
- 引导方法和运行方法之间的角度有什么区别
- 基于集合侦听器运行方法的主干
- 运行方法中的Angular$q服务实现
- 在第一个方法完成后运行方法
- AngularFire:在$firebaseArray更改时运行方法
- 如何在用户关闭浏览器时在控制器中运行方法
- $.ajax()成功调用,但不会运行方法
- AngularJS:如何保持在'运行'方法,直到完成
- 在"add"事件上运行方法的Backbone Collection获取:";TypeErr