2
我有一個網址像這樣:http://foo.bar/#/some/other/path
捕獲所有路線參數
如何捕捉「一些/其它/路徑」作爲路由參數?
我嘗試這樣做:
var App = angular.module("App", [])
.config(function($routeProvider){
$routeProvider
.when('/:path', { controller: ListCtrl, templateUrl: 'list.html'})
.otherwise({ redirectTo: '/'})
});
但:path
只給我some
而不是some/other/path
作爲即將發佈的穩定版本1.2的一部分,您會發現catch-all功能,或者如果您不介意切換到_unstable_ 1.1.3,您可以立即擁有它。這裏是[提交](https://github.com/angular/angular.js/commit/7eafbb98c64c0dc079d7d3ec589f1270b7f6fea5)(含文檔)。 – Stewie 2013-03-20 10:09:05
謝謝!升級到1.1.3工作!有沒有辦法在URL中進行部分匹配?例如,我想在'http://foo.bar /#/ some/other/path/image.jpg'中匹配'.jpg' – Chanpory 2013-03-20 22:26:56
不確定,但是這裏有一個關於正在進行的討論的鏈接列表新的角度路由](https://github.com/angular/angular.js/wiki/Routing-Design-Discussion)。也許你會在那裏找到答案。 – Stewie 2013-03-20 22:37:15