我找不出在我的代碼中發生了什麼,所以這就是我認爲在論壇上發佈我的問題的原因。頁面在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談談嗎? –