AngularJS を使用している ASP.NET MVC5 アプリがあります。これには、 と呼ばatTheMS
れるサービスのファクトリalbumService
と 3 つのコントローラーで呼び出されるモジュールがあります: ListController
、EditController
、およびDetailsController
。サービスとコントローラーはすべてモジュールに依存していatTheMS
ますが、このエラーは以下からのみ発生しますalbumService
Uncaught Error: [$injector:nomod] Module 'atTheMS' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
それはそれがで起こっていると言います(anonymous function) albumService.js:27
(function (app) {
var albumService = function ($http, albumApiUrl) {
var getAll = function () {
return $http.get(albumApiUrl);
};
var getById = function (id) {
return $http.get(albumApiUrl + id);
};
var update = function (album) {
return $http.put(albumApiUrl + album.Id, album);
};
var create = function (album) {
return $http.post(albumApiUrl, album);
};
var destroy = function (album) {
return $http.delete(albumApiUrl + album.Id);
};
return {
getAll: getAll,
getById: getById,
update: update,
create: create,
delete: destroy
};
};
app.factory("albumService", albumService);
}(angular.module("atTheMS")));
使用する他のファイルではエラーは発生しません。(angular.module("atTheMS"))
これは、「アルバム」という単語が「本」という単語に置き換えられ、モジュールが「atTheLibrary」であり、モジュールがないことを除いて、まったく同じである別のファクトリをコピーして生成されました。そのページにいるときのエラー。なぜこれが違うのか、私は混乱しています。どんな助けでも感謝します、ありがとう。
リクエストに応じて、ビューは次のとおりです。
@section scripts {
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/angular-route.js"></script>
<script src="~/Client/Scripts/Album/albumService.js"></script>
<script src="~/Client/Scripts/Album/atTheMS.js"></script>
<script src="~/Client/Scripts/Album/ListController.js"></script>
<script src="~/Client/Scripts/Album/DetailsController.js"></script>
<script src="~/Client/Scripts/Album/EditController.js"></script>
}
<div data-ng-app="atTheMS">
<ng-view></ng-view>
</div>
<hr />