頁碼引數

int 類似,但只接受正整數(當有 page 引數時,對於分頁很有用。

限定:

module.config(['$urlMatcherFactoryProvider', function($urlMatcherFactory) {
  $urlMatcherFactory.type('page', {
    decode: function(val) { return +val; },
    encode: function(val) { return Math.floor(val); },
    equals: function(a, b) { return this.is(a) && +a == +b; },
    is: function(val) { return angular.isNumber(val) && val >= 1; },
    pattern: /\d+/
  })
}]);

並使用:

$stateProvider.state({
  url: '/my-route/{page:page}'
  template: '<my-page></my-page>'
});

Plunker相關的 SO 答案