我有一個路由方案,其中#/articles
導致articles.html
視圖,而#/articles/featured
導致featured.html
。不過,我不確定如何聲明這個嵌套的文字。如果我按照以下方式配置我的路線,則#/articles
和#/articles/featured
都會導致articles.html
(因爲兩個路徑都匹配r'^ articles)。Angular Dart中的嵌套路由
library my_router;
import 'package:angular/angular.dart';
class MyRouteInitializer implements RouteInitializer {
init(Router router, ViewFactory view) {
router.root
..addRoute(
name: 'articles',
path: '/articles',
enter: view('views/articles.html'),
mount: (Route route) => route
..addRoute(
name: 'featured',
path: '/featured',
enter: view('views/featured.html'))
);
}
}
如果我省略了enter: view('views/articles.html')
線,該#/articles/featured
路線正確路線featured.html
,但再沒有什麼路線articles.html
。
謝謝,這非常有幫助。 –
您能否使用嵌套的'ng-view'來返回示例 –
@pavelgj我在主頁上只有一個ng-view。儘管路由嵌套在邏輯上,但它們不是通過嵌套的ng-views呈現的。那麼,我的路由器應該如何。建議在路由器中使用嵌套結構還是應該採用扁平結構? [這個問題是關於假設這種方法在這種情況下效果最好的最佳做法] – Amsakanna