2014-12-13 58 views
2

我正在創建一個AngularJS應用程序,它將從The Guardian API獲取內容。我使用路由,所以當它位於「articles /:articleId」時,我可以獲取articleId參數。在這種情況下,「文章/ 123」工作正常,則返回123,但監護人API ID是:AngularJS路由參數隨機數斜線

technology/competition/2013/nov/01/observer-tech-monthly-student-competition 

所以,它不承認新聞/:條款ArticleID的路線了,相反,它會跳過該控制器並返回到正常(.otherwise())控制器。是否有任何方法可以在/ news後得到整件事情,在這種情況下,將返回整個參數:

technology/competition/2013/nov/01/observer-tech-monthly-student-competition 

謝謝。

+0

你能發佈代碼嗎? – Mou 2014-12-13 12:42:55

回答

2

角1.1.5引入*path

例如,路線等

`/color/:color/largecode/*largecode/edit` 

將匹配

`/color/brown/largecode/code/with/slashs/edit` 

和提取:

color: brown 
largecode: code/with/slashs 

角1.3,在語法改變:path*

總之,如果你正在使用角1.3,我想你想你的路線,看起來像這樣:

articles/:articleId* 
+0

正是我在找的東西。非常感謝! – 2014-12-13 12:53:29