この angular サービスは、コンパイルされていない JavaScript で正常に動作します。しかし、Google クロージャーのコンパイル後、サービスの検索に失敗します。コンパイルされたコードのデバッグが困難。
何が問題なのか分かりますか? ファイル 1:
'use strict';
goog.provide('simpleDialogService');
angular.module(‘myApp').service('simpleDialogService', ['$modal',
function ($modal) {
var dialogDefaults = {};
dialogDefaults ['templateUrl'] = "partials/dialog.html";
var dialogOptions = {};
dialogOptions ['cancelButtonVisibility'] = "hidden";
var dialogResults = {};
// other functions, including showDialog()
this[‘showModalDialog’] = function (customDialogDefaults, customDialogOptions) {
if (!customDialogDefaults) customDialogDefaults = {};
customDialogDefaults['backdropClick'] = false;
return this.showDialog(customDialogDefaults, customDialogOptions);
};
}]);
ファイル 2:
goog.require('extern.jquery');
goog.require('simpleDialogService');
file2 で次のように呼び出されます。
function anotherFunction(){
var promise;
var injector = angular.injector(['ng', ‘myApp']);
injector.invoke(['simpleDialogService', function(simpleDialogService){
promise = simpleDialogService['showModalDialog']({}, dialogOptions);
}]);
return promise;
}
またはこのように呼び出します
function anotherFunction2(){
var promise;
var injector = angular.injector(['ng', ‘myApp']);
var myService = theInjector.get('simpleDialogService');
promise = myService['showModalDialog']({}, dialogOptions);
return promise;
}
どちらの形式もコンパイルされていない状態で動作します。
クロージャコンパイルに適した方法でこれを行う方法を誰かが提案できますか?