Asp.net 如何在角路由中附加URL?

Asp.net 如何在角路由中附加URL?,asp.net,angularjs,asp.net-mvc-5,angularjs-ng-repeat,angular-ui-router,Asp.net,Angularjs,Asp.net Mvc 5,Angularjs Ng Repeat,Angular Ui Router,如何在角路由中进行url(字符串)共分类 请参考下面的片段来理解我的问题 app.config(['$routeProvider','$location'],函数($routeProvider){ 当(“/”{ templateUrl:“/AlbumsList.html”, 控制器:“a1Ctrl” }). 当(“/albums/:albumName”{ templateUrl:'AlbumsList.html', 控制器:“b1Ctrl” }) }) app.controller('a1Ct

如何在角路由中进行url(字符串)共分类

请参考下面的片段来理解我的问题

app.config(['$routeProvider','$location'],函数($routeProvider){
当(“/”{
templateUrl:“/AlbumsList.html”,
控制器:“a1Ctrl”
}).
当(“/albums/:albumName”{
templateUrl:'AlbumsList.html',
控制器:“b1Ctrl”
})
})
app.controller('a1Ctrl',函数($scope,$http){
$scope.albums=function(){
//ajax从服务器获取数据
}
})
应用控制器('b1Ctrl',函数($scope,$routeProviders){
$scope.album=$routeProviders.albumName;
$http({
//与上述从服务器获取nes子相册数据的ajax功能相同
})
})


您需要更改
$routeProvider。当
url选项时,它将接受两个参数,一个是
albumType
,另一个是
alubmName
。您可以使用
$routeParams
服务在
b1Ctrl
中获取这些值

标记

<li ng-repeat="album in albums">
  <a ng-href="/albums/{{alubm.type}}/{{album.name}}">{{album.name}}</a>
</li>
然后在控制器内部,您应该使用
$routeParams
而不是
$routeProviders

控制器

app.controller('b1Ctrl', function($scope, $routeParams) {
  $scope.album = $routeParams.albumName;
  $scope.albumType = $routeParams.albumType; //alumType eg. hindi , english, etc

  $http({
    //same ajax function as above getting data from server for the nes sub album
  })
});
app.controller('b1Ctrl', function($scope, $routeParams) {
  $scope.album = $routeParams.albumName;
  $scope.albumType = $routeParams.albumType; //alumType eg. hindi , english, etc

  $http({
    //same ajax function as above getting data from server for the nes sub album
  })
});