我有一个使用 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"))
,这是复制我拥有的另一个工厂而生成的,除了单词“album”被单词“book”替换并且模块是“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 />