私はこれを理解することはできません。injection
現在、より多くのドキュメントに飛び込んでいますが、なぜこれが機能しないのかわかりません。以下の例では、undefinedmyConstants.defaultPath
としてログに記録します。
(function() {
angular.module('my-constants', []).factory('myConstants', [
function() {
var service;
return service = {
defaultPath: '/aroute'
};
}
]);
}).call(this);
(function() {
var app, config;
app = angular.module('my-app', ["my-constants"]);
config = function($routeProvider, $httpProvider, myConstants) {
console.log(myConstants.defaultPath); // undefined
return $routeProvider.otherwise({
redirectTo: myConstants.defaultPath
});
};
config.$inject = ['$routeProvider', '$httpProvider', 'myConstantsProvider'];
app.config(config);
}).call(this);