小编ten*_*i_a的帖子

.NET MVC路由 - 在路由开始时捕获?

有什么方法可以匹配:

/a/myApp/Feature

/a/b/c/myApp/Feature

/x/y/z/myApp/Feature
Run Code Online (Sandbox Code Playgroud)

有一条路线不明确知道myApp/Feature之前的路径是什么?

我基本上想做的是:

RouteTable.Routes.MapRoute(
  "myAppFeatureRoute", "{*path}/myApp/Feature",
  new { controller = "myApp", action = "Feature" });
Run Code Online (Sandbox Code Playgroud)

但是你不能在路线的开头放一个笼子.

如果我只是尝试"{path}/myApp/Feature",那将匹配"/ a/myApp/Feature"而不是"/ a/b/c/myApp/Feature".

我也尝试了一个正则表达式,但没有任何帮助.

RouteTable.Routes.MapRoute(
  "myAppFeatureRoute", "{path}/myApp/Feature",
  new { controller = "myApp", action = "Feature", path = @".+" });
Run Code Online (Sandbox Code Playgroud)

我这样做的原因是我正在构建一个在CMS中使用的功能,并且可以位于站点结构中的任何位置 - 我只能确定路径的结束,而不是开头.

c# asp.net-mvc-routing asp.net-mvc-4

7
推荐指数
1
解决办法
1212
查看次数

AngularJS - 选择列表中第一个在模板中重新排序的选项

我昨天刚开始使用Angular JS,对不起,如果我问一些明显的东西.我要做的是在我的选择中选择默认选择的第一个选项,但由于它是在前端订购的,因此选择了错误的选项.我想在选择第一项之前,我应该重新排序从控制器内部的API调用中返回的数据?

这是我的选择:

<select ng-model="clientsList" ng-options="c.Name for c in clients | orderBy:'Name'"></select>
Run Code Online (Sandbox Code Playgroud)

这是我的控制器:

function MyCtrl($scope, $http) {
    $scope.init = $http.jsonp('http://MY-API?callback=JSON_CALLBACK')
    .then( function ( response ) {
        $scope.clients = response.data;
        // need to select something, unfortunately, this won't be the first option on the front end because it's re-ordered alphabetically there
        $scope.clientsList = $scope.clients[0];
    });
}
Run Code Online (Sandbox Code Playgroud)

javascript filtering angularjs

3
推荐指数
1
解决办法
4007
查看次数