angular-route:是否可以在基本网址中设置路由参数?

时间:2016-02-17 15:47:12

标签: angularjs angular-routing

是否可以在基本网址中使用ngRoute设置路由参数?

 <base href="/some/resource/path/:myParameter/" />

与:

 angular.module('myApp', ['ngRoute'])
.config(["$routeProvider", "$locationProvider", function ($routeProvider, $locationProvider) {
    $routeProvider
    .when('/first', {
        templateUrl: 'template.html',
        controller: 'mainController'
    })
    .when('/second', {
        templateUrl: 'template.html',
        controller: 'mainController'
    })
    .when('/third', {
        templateUrl: 'template.html',
        controller: 'someController'
    })
    .when('/forth', {
        templateUrl: 'template.html',
        controller: 'someController'
    })
    .otherwise({
        redirectTo: '/first'
    });

     $locationProvider.html5Mode(true);
}]);

获取路线:

/some/resource/path/:myParameter/first
/some/resource/path/:myParameter/second
/some/resource/path/:myParameter/third
/some/resource/path/:myParameter/forth

0 个答案:

没有答案