我試圖uglify我的AngularJS代碼。我跟所有在互聯網上的教程現在有下面的代碼,但uglifying後,我仍然得到和錯誤:
var app = angular.module('myapp', ['ngMaterial', 'pascalprecht.translate', 'ngSanitize', 'material.components.expansionPanels', 'ngFileSaver', 'ngMessages', 'ngFileUpload', 'ngStorage']
TestController.$inject = ['$scope', '$translate', '$timeout','$mdSidenav', '$log', '$sessionStorage'];
angular.module('myapp').controller('TestController', TestController);
function TestController ($scope, $translate, $timeout, $mdSidenav, $log, $sessionStorage) {}
編輯: 我已經找到了問題。問題是我的可配置模塊:
app.config(function ($locationProvider) {
$locationProvider.html5Mode(true);
});
不是:
app.config(['$locationProvider', function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
app.directive('onReadFile', function ($parse) {
return {
restrict: 'A',
scope: false,
link: function(scope, element, attrs) {
var fn = $parse(attrs.onReadFile);
element.on('change', function(onChangeEvent) {
var reader = new FileReader();
reader.onload = function(onLoadEvent) {
scope.$apply(function() {
fn(scope, {$fileContent:onLoadEvent.target.result});
});
};
reader.readAsText((onChangeEvent.srcElement || onChangeEvent.target).files[0]);
});
}
};
});
是您模塊的名稱'myapp'(全部小寫)或'myApp'(駱駝)? – Makoto
語法在這裏不是問題! – thigi
考慮到您在注射器方面存在問題......是的。這裏沒有足夠的信息來說明它是什麼;你能告訴我們你的模塊中依賴哪些服務嗎? – Makoto