9

angularjs が emberjs のようなネストされたルートをサポートしているかどうかを知りたいのですが、次のようなルートを意味します。myappurl/#/company/:company_id/department/:department_id

4

3 に答える 3

7

ui-routerこのタスクを実行する以外に、別の Angular ライブラリがあることに言及する価値があります。これも機能します:

http://angular-route-segment.com

ui-router よりもはるかに簡単に使用できます。サンプルのルート構成は次のようになります。

$routeSegmentProvider.

when('/section1',          's1.home').
when('/section1/prefs',    's1.prefs').
when('/section1/:id',      's1.itemInfo.overview').
when('/section1/:id/edit', 's1.itemInfo.edit').
when('/section2',          's2').

segment('s1', {
    templateUrl: 'templates/section1.html',
    controller: MainCtrl}).

within().

    segment('home', {
        templateUrl: 'templates/section1/home.html'}).

    segment('itemInfo', {
        templateUrl: 'templates/section1/item.html',
        controller: Section1ItemCtrl,
        dependencies: ['id']}).

    within().

        segment('overview', {
            templateUrl: 'templates/section1/item/overview.html'}).

        segment('edit', {
             templateUrl: 'templates/section1/item/edit.html'}).

        up().

    segment('prefs', {
        templateUrl: 'templates/section1/prefs.html'}).

    up().

segment('s2', {
    templateUrl: 'templates/section2.html',
    controller: MainCtrl});
于 2013-08-15T10:15:39.720 に答える
3

ドキュメントに記載されている例によると: https://docs.angularjs.org/api/ngRoute/directive/ngView。はい、Angularjs はそれをサポートしています。

于 2012-10-08T22:35:41.827 に答える
3

https://github.com/angular-ui/ui-routerもチェックする価値があります

于 2013-03-25T09:06:59.597 に答える