C# $injector:moduler未能实例化模块my分支
无法实例化模块C# $injector:moduler未能实例化模块my分支,c#,angularjs,C#,Angularjs,无法实例化模块我的分支,原因是: [$injector:nomod]模块'my-branchs'不可用!您要么拼错了模块名,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数 \u Layout.cshtml {{3+3}} @Html.Partial(“\u导航”) @Html.Partial(“\u TopNavbar”) @RenderBody() @Html.Partial(“\u Footer”) @Scripts.Render(“~/bundles/jquery”) @S
我的分支
,原因是:
[$injector:nomod]模块'my-branchs'
不可用!您要么拼错了模块名,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数
\u Layout.cshtml
{{3+3}}
@Html.Partial(“\u导航”)
@Html.Partial(“\u TopNavbar”)
@RenderBody()
@Html.Partial(“\u Footer”)
@Scripts.Render(“~/bundles/jquery”)
@Scripts.Render(“~/bundles/angular”)
@Scripts.Render(“~/bundles/bootstrap”)
@Scripts.Render(“~/plugins/metsiMenu”)
@Scripts.Render(“~/plugins/pace”)
@Scripts.Render(“~/plugins/slimScroll”)
@Scripts.Render(“~/bundles/inspinia”)
@RenderSection(“脚本”,必需:false)
Index.cshtml
分支详细信息-网格积垢操作
分支机构地址
分支机构电子邮件
分支机构名称
分支票据
行动
{{branche.Address}
{{branche.Email}
{branche.Name}
{{branche.Notes}
@节脚本{
Controller.js
myapp.controller('branch-controller', function ($scope, branchService) {
//Loads all branch records when page loads
loadBranches();
function loadBranches() {
var BrancheRecords = branchService.getAllBranches();
BrancheRecords.then(function (d) {
//success
$scope.Branches = d.data;
},
function () {
alert("Error occured while fetching branche list...");
});
}
});
**Module.js**
var myapp;
(function () {
myapp = angular.module('my-branches', []);
})();
**Service.js**
myapp.service('branchService', function ($http) {
this.getAllBranches = function () {
return $http.get("/Branches/Index");
};
});
**捆绑图**
public static void RegisterBundles(BundleCollection bundles)
{
// Vendor scripts
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-2.1.1.min.js",
"~/Scripts/jquery.unobtrusive-ajax.js",
"~/Scripts/branches.js"));
// jQuery Validation
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate.min.js"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.min.js"));
// Inspinia script
bundles.Add(new ScriptBundle("~/bundles/inspinia").Include(
"~/Scripts/app/inspinia.js"));
// SlimScroll
bundles.Add(new ScriptBundle("~/plugins/slimScroll").Include(
"~/Scripts/plugins/slimScroll/jquery.slimscroll.min.js"));
// jQuery plugins
bundles.Add(new ScriptBundle("~/plugins/metsiMenu").Include(
"~/Scripts/plugins/metisMenu/metisMenu.min.js"));
bundles.Add(new ScriptBundle("~/plugins/pace").Include(
"~/Scripts/plugins/pace/pace.min.js"));
// CSS style (bootstrap/inspinia)
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.min.css",
"~/Content/animate.css",
"~/Content/style.css"));
// Font Awesome icons
bundles.Add(new StyleBundle("~/font-awesome/css").Include(
"~/fonts/font-awesome/css/font-awesome.min.css", new CssRewriteUrlTransform()));
bundles.Add(new ScriptBundle("~/bundles/angular").Include(
"~/Scripts/angular.js",
"~/Scripts/angular-route.js"));
}
这里发生的情况是,当加载布局页面时,它找不到应用程序声明,因为它尚未下载(Module.js文件) 您应该在BundleConfig.cs中创建一个包含所有应用程序文件的额外捆绑包:
bundles.Add(new ScriptBundle("app").Include(
"~/Scripts/AngularJSApp/Branches/Module.js",
"~/Scripts/AngularJSApp/Branches/Service.js",
"~/Scripts/AngularJSApp/Branches/Controller.js"));
并将其添加到_布局文件中的库捆绑包下