我使用状态提供程序映射网址,以下是我的AngularJS代码。
.state('uimenucategories', {
url: "/MenuCategory.html",
templateUrl: "/AppMenuMaker/MenuCategory",
data: {pageTitle: 'Menu Category'},
controller: "MenuCategoryController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([{
name: 'MetronicApp',
files: [
'js/controllers/MenuCategoryController.js',
]
}]);
}]
}
})
我想从URL中获取参数,以便在渲染视图之前将它们传递给操作
public ActionResult MenuCategory(int? CategoryID){}
有关如何从此网址Dashboard/Index#/ViewMenuCategories.html?ID=1
发送这些内容的任何帮助
?
答案 0 :(得分:0)
如果您在浏览器上点击了“Dashboard / Index#/ ViewMenuCategories.html?ID = 1”网址,则angular会在'/ AppMenuMaker / MenuCategory上搜索模板?CategoryID = 1'。
我认为代码是:
.state('uimenucategories', {
url: "/MenuCategory.html",
templateUrl: ['$location', function($location){
return '/AppMenuMaker/MenuCategory?CategoryID=' + $location.search().ID || '';
}
}],
data: {pageTitle: 'Menu Category'},
controller: "MenuCategoryController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([{
name: 'MetronicApp',
files: [
'js/controllers/MenuCategoryController.js',
]
}]);
}]
}
})
控制器/动作:
public ActionResult MenuCategory(int? CategoryID)
{
return View('');
}
您需要在应用中引用Angular Route才能使用 $ location 服务。