我找不出在我的代码中发生了什么,所以这就是我认为在论坛上发布我的问题的原因。页面在Angular JS 1.5中冻结?
我想在我的Asp.Net MVC 5.0应用程序中使用AngularJS 1.5实现动态菜单,但只要我导航到其他菜单页面冻结,所以你们可以请你帮我为什么我的网页冻结了。
对不起所以任何人请点我要填充菜单无法弄清楚究竟是什么问题...
代码 “_Layout.cshml”
<header>
<nav ng-init="fillMenuController()" ng-controller="LayoutCtrl" class="navbar-inverse">
<div class="container-fluid">
<div class="navbar-header"></div>
<script type="text/ng-template" id="treeMenu">
<a class="dropdown-toggle" href="{{menu.URL}}" ng-attr-data-toggle="{{menu.URL == '#'?'dropdown':''}}">
{{menu.LinkText}}
<span ng-if="(MenuList | filter:{ParentCategoryID : menu.ID}).length > 0">
<span class="caret"></span>
<ul ng-hide="(MenuList | filter:{ParentCategoryID : menu.ID}).length == 0" class="dropdown-menu">
<li ng-repeat="x in MenuList | filter: {ParentCategoryID : menu.ID}">
<a href="{{x.URL}}">{{x.LinkText}}</a>
</li>
</ul>
</span>
</a>
</script>
<div class="navbar-header"><a href="#"><img class="img-responsive AngularJS-small" src="~/Images/ACE.jpg" style="height: 40px; padding-top: 10px;" /></a></div>
<ul class="nav navbar-nav">
<li class="dropdown" ng-repeat="menu in MenuList | filter: {ParentCategoryID : 0}" ng-include="'treeMenu'" />
<li id="btnLogOut"><a href="#">Log out</a></li>
</ul>
</div>
控制器代码
app.controller("LayoutCtrl", function ($scope, LayoutService, common) {
$scope.MenuList = [];
$scope.fillMenuController = function() {
var MenuMasterData = LayoutService.GetMenuMaster()
MenuMasterData.then(function (response) {
if (response.data.length == 0) { return; }
$scope.MenuList = response.data;
}, function (response) {
if (response.data != null)
{
common.ShowMessage(response.data);
}
});
}
});
app.service("LayoutService", function ($http) {
this.GetMenuMaster = function() {
var response = $http({
method: 'get',
url: "/Layout/GetMenuMaster",
params: {},
cache: true
})
return response;
};
});
数据库代码来填充动态菜单:
public JsonResult GetMenuMaster()
{
SAPDataContext objSAPDataContext = new SAPDataContext();
try
{
List<BE_Menu> lstMenu = new List<BE_Menu>
{
new BE_Menu { ID = 1, LinkText = "Activity", URL="/CRM/Activity/", ParentCategoryID = 0 },
new BE_Menu { ID = 2, LinkText = "Business Partners", URL="/CRM/BusinessPartner/", ParentCategoryID = 0 },
new BE_Menu { ID = 3, LinkText = "Sales", URL="#", ParentCategoryID = 0 },
new BE_Menu { ID = 4, LinkText = "Sales Opportunities", URL="/Opportunity/OpportunityMaster", ParentCategoryID = 3 },
new BE_Menu { ID = 5, LinkText = "Sales Quotation", URL="/CRM/SalesQuotation/", ParentCategoryID = 3 },
new BE_Menu { ID = 6, LinkText = "Sales Order", URL="/CRM/SalesOrder/", ParentCategoryID = 3 },
new BE_Menu { ID = 7, LinkText = "Delivery", URL="/CRM/Delivery/", ParentCategoryID = 0 },
new BE_Menu { ID = 8, LinkText = "Service Call", URL="/CRM/ServiceCall/", ParentCategoryID = 0 },
new BE_Menu { ID = 9, LinkText = "Customer Equipment Card", URL="/CRM/EquipmentCard/", ParentCategoryID = 0 }
};
return Json(lstMenu, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
throw ex;
}
finally
{
objSAPDataContext.Dispose();
}
}
现在从我身边的一些输入刚才我偶然发现了这个错误:http://localhost:36167/Scripts/AngularJS/angular.min.js
在线路133未处理的异常,列345 0x800a139e - JavaScript运行时错误:[$ rootScope:inprog] http://errors.angularjs.org/1.5.0/ $ rootScope/inprog?p0 =%24diges
感谢您的回复......根据你输入我修改了代码,但没有工作....大家可以看一下这个问题togerther通过Skype? t –
使您的问题简化提琴 – tomcater
当我们从一个页面导航到另一个时,问题出现了,我不这么认为我可以使用提琴手来设置所有的东西......我们可以通过Skype谈谈吗? –