Javascript 在高级_模式下将闭包编译器与AngularJS一起使用
我正试图编译一个angular&openLayers项目,但我不能使用angular 我已经输入了angular外部参数,但编译后出现以下错误:Javascript 在高级_模式下将闭包编译器与AngularJS一起使用,javascript,angularjs,google-closure-compiler,Javascript,Angularjs,Google Closure Compiler,我正试图编译一个angular&openLayers项目,但我不能使用angular 我已经输入了angular外部参数,但编译后出现以下错误: Error: [$injector:unpr] Unknown provider: aProvider <- a <- myCtrl http://errors.angularjs.org/1.3.15/$injector/unpr?p0=aProvider%20%3C-%20a%20%3C-%20myCtrl at REGEX_S
Error: [$injector:unpr] Unknown provider: aProvider <- a <- myCtrl
http://errors.angularjs.org/1.3.15/$injector/unpr?p0=aProvider%20%3C-%20a%20%3C-%20myCtrl
at REGEX_STRING_REGEXP (angular.js:63)
at angular.js:4015
at Object.getService [as get] (angular.js:4162)
at angular.js:4020
at getService (angular.js:4162)
at Object.invoke (angular.js:4194)
at $get.extend.instance (angular.js:8493)
at angular.js:7739
at forEach (angular.js:331)
at nodeLinkFn (angular.js:7738)
要编译这些文件,我使用以下命令:
python closure-library/closure/bin/build/closurebuilder.py
--root=closure-library/
--root=../debug/
--namespace="vmap"
--output_mode=compiled
--compiler_jar=compiler.jar
--compiler_flags="
--compilation_level=ADVANCED_OPTIMIZATIONS"
--compiler_flags="--externs=../debug/lib/angular/angular-1.3.js"
--compiler_flags="--angular_pass" > ../vmap.js
我找到了angular-1.3.js文件
我错过了什么?使用数组表示法编写控制器:
app.controller('myCtrl', ['$scope', function($scope) {
$scope['firstName'] = "John";
$scope['lastName'] = "Doe";
}]);
由于局部变量(如$scope)被重命名,对象属性($scope.firstName)也被重命名,除非您使用字符串表示法编写它们
有关AngularJS缩小的更多信息,请参见:
@ngInject
app.controller('myCtrl',fn)
--angular\u pass
参数传递给闭包编译器goog.provide(“vmap”);
/**
*@constructor
*@ngInject
*/
vmap=功能($scope){
$scope.firstName=“John”;
$scope.lastName=“Doe”;
};
var-app=angular.module('myApp',[]);
应用控制器('myCtrl',vmap);
看起来您正在缩小代码,但角度代码的编写方式不允许缩小。看看这篇博文,它涵盖了可以缩小的角度代码
python closure-library/closure/bin/build/closurebuilder.py
--root=closure-library/
--root=../debug/
--namespace="vmap"
--output_mode=compiled
--compiler_jar=compiler.jar
--compiler_flags="
--compilation_level=ADVANCED_OPTIMIZATIONS"
--compiler_flags="--externs=../debug/lib/angular/angular-1.3.js"
--compiler_flags="--angular_pass" > ../vmap.js
app.controller('myCtrl', ['$scope', function($scope) {
$scope['firstName'] = "John";
$scope['lastName'] = "Doe";
}]);