Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency Injector尝试采用数组形式 #8

Open
Hosuke opened this issue Feb 2, 2015 · 1 comment
Open

Dependency Injector尝试采用数组形式 #8

Hosuke opened this issue Feb 2, 2015 · 1 comment

Comments

@Hosuke
Copy link

Hosuke commented Feb 2, 2015

在使用uglify的时候,他会把function checkInCtrl ($scope, $rootScope, $location, $http){
}的申明变为类似于function checkInCtrl(a,b,c,d){
},这样注入会有问题。所以需要采用数组注入,才能让他正确的对应

潜在问题:grunt以后自动化打包压缩script会因为打乱文件压缩顺序出问题, 比如依赖jquery的js文件在jquery文件加入合并之前就已经自动了

@sammok
Copy link

sammok commented Feb 5, 2015

👍 嗯, 对~~ 详细点的问题描述在下方:

  • 将 dependencies injector 改用数组形式injector, 避免 uglify或者其他js压缩插件 在compression时将 function parameter name更改为短小的字母而发生 parameter invoke错误

eg:

controller(‘IndexController’, function ($scope){ $scope.name = ‘wolf'})

when use uglify to compression..it will occur an error below

controller(‘IndexController’,function (e){ e.name = ‘wolf’}) // as you can see the parameter name $scope to be instead with e

the better way to void that error to use array to injector your controller dependencies

controller(‘IndexController’, [‘$scope’, function (){ $scope.name = ‘wolf’;}]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants