以下代码不适用于参数传递
<li class="active" ng-disabled="disabledAction"><a href="#!/Reservation/821" ><i class="fa fa-fw fa-pencil-square-o icon-push"></i>{{langResources.EditReservation}}</a></li>
点击此链接会重定向到控制器下方但不会获取参数值ie,821
[HttpGet]
public ActionResult HotelReservation(long resId = 0)
{
ViewBag.resId = resId;
return PartialView();
}
$routeProvider.when('/Reservation/:ResId', {
templateUrl: '/Home/HotelReservation/resId=ResId',
controller: 'HotelReservationCtrl',
activetab: 'Reservation'
});
答案 0 :(得分:0)
我认为你必须改变什么时候?
$routeProvider.when('/Reservation/:ResId?', {
templateUrl: '/Home/HotelReservation/resId=ResId',
controller: 'HotelReservationCtrl',
activetab: 'Reservation'
});
。
因为它期望MVC控制器中的resId参数值。
所以在锚标记中执行此<a href="#!/Reservation?resId=821" >
答案 1 :(得分:0)
现在它正在运作。
代码更改为
$routeProvider.when('/Reservation/:ResId', {
templateUrl: function (params) {
var url='/Home/HotelReservation?resId=' + params.ResId;
return url},
controller: 'HotelReservationCtrl',
activetab: 'Reservation'
});