• <tfoot id='bDSFb'></tfoot>
    <i id='bDSFb'><tr id='bDSFb'><dt id='bDSFb'><q id='bDSFb'><span id='bDSFb'><b id='bDSFb'><form id='bDSFb'><ins id='bDSFb'></ins><ul id='bDSFb'></ul><sub id='bDSFb'></sub></form><legend id='bDSFb'></legend><bdo id='bDSFb'><pre id='bDSFb'><center id='bDSFb'></center></pre></bdo></b><th id='bDSFb'></th></span></q></dt></tr></i><div id='bDSFb'><tfoot id='bDSFb'></tfoot><dl id='bDSFb'><fieldset id='bDSFb'></fieldset></dl></div>

      <small id='bDSFb'></small><noframes id='bDSFb'>

      <legend id='bDSFb'><style id='bDSFb'><dir id='bDSFb'><q id='bDSFb'></q></dir></style></legend>

      • <bdo id='bDSFb'></bdo><ul id='bDSFb'></ul>
      1. 如何处理角度5递归未知确切数字路由器参数?

        How to handle angular 5 recursive unknown exact number router parameters?(如何处理角度5递归未知确切数字路由器参数?)
            <tbody id='1L9lB'></tbody>
          <tfoot id='1L9lB'></tfoot>

          • <small id='1L9lB'></small><noframes id='1L9lB'>

              <bdo id='1L9lB'></bdo><ul id='1L9lB'></ul>
            • <legend id='1L9lB'><style id='1L9lB'><dir id='1L9lB'><q id='1L9lB'></q></dir></style></legend>

              <i id='1L9lB'><tr id='1L9lB'><dt id='1L9lB'><q id='1L9lB'><span id='1L9lB'><b id='1L9lB'><form id='1L9lB'><ins id='1L9lB'></ins><ul id='1L9lB'></ul><sub id='1L9lB'></sub></form><legend id='1L9lB'></legend><bdo id='1L9lB'><pre id='1L9lB'><center id='1L9lB'></center></pre></bdo></b><th id='1L9lB'></th></span></q></dt></tr></i><div id='1L9lB'><tfoot id='1L9lB'></tfoot><dl id='1L9lB'><fieldset id='1L9lB'></fieldset></dl></div>

                  本文介绍了如何处理角度5递归未知确切数字路由器参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法处理递归未知的确切数量的路由器参数?

                  Is there a way to handle recursively unknown exact number of router parameters?

                  例如:

                  我们有产品类别,其中可以有子类别,子类别可以有自己的子类别等等.有几个主要条件:

                  We have products categories, which can have subcategories, subcategories can have it's own subcategories and so on. There are a few main conditions:

                  • 如果此类类别没有子类别,我们将重定向到 /categories/{id}/items,这将打开项目列表组件.
                  • 如果类别有子类别,它应该被重定向到下一个嵌套树级别 /categories/{id}/{id}/.../{id} 这应该打开最后一个 categoryId 子类别列表组件.
                  • 在到达最后一个没有子类别项目列表组件的类别后,将显示 /categories/{id}/{id}/.../{id}/items.
                  • if a such category has no subcategories we redirect to /categories/{id}/items that will open items list component.
                  • if category has subcategory it should be redirected to next nested tree level /categories/{id}/{id}/.../{id} which should open the last categoryId subcategories list component.
                  • after getting to the last category which doesn't has subcategories items list component will be shown /categories/{id}/{id}/.../{id}/items.

                  检查和重定向的解决方案是使用路由器解析器.但是如何在路由模块中跟踪这些 url 呢?

                  The solutions to check and redirect is to have router resolver. But how track those urls in routing module ?

                  在我看来,路线应该是这样的:

                  From my perspective the routes should look something like this:

                  {
                    path: '/categories/:id',
                    component: SubcategoriesListComponent
                  },
                  {
                    path: '/categories/:id/**/:id',
                    component: SubcategoriesListComponent,
                  },
                  {
                    path: '/categories/:id/**/:id/items',
                    component: CategoryItemsListComponent
                  }
                  

                  可以这样实现吗?

                  推荐答案

                  无组件路由的可能解决方案:在路线配置中

                  Possible solution with componentless routes: in routes config

                  {
                      path: 'categories/:id', children: [
                      {path: '**', component: SubcategoriesListComponent}
                  ]
                  }
                  

                  在组件文件中:

                  export class SubcategoriesListComponent {
                  
                    constructor(aroute: ActivatedRoute) {
                      aroute.url.subscribe((data) => {
                        console.log('params ', data); //contains all the segments so put logic here of determining what to do according to nesting depth
                      });
                  
                    }
                  
                  }
                  

                  这里是 输出示例(我在我的项目 ErrorComponent 上测试过,所以不要混淆)

                  Here is the output example (i tested on my project ErrorComponent so don't be confused)

                  这篇关于如何处理角度5递归未知确切数字路由器参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                  How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)

                    <i id='dP8CQ'><tr id='dP8CQ'><dt id='dP8CQ'><q id='dP8CQ'><span id='dP8CQ'><b id='dP8CQ'><form id='dP8CQ'><ins id='dP8CQ'></ins><ul id='dP8CQ'></ul><sub id='dP8CQ'></sub></form><legend id='dP8CQ'></legend><bdo id='dP8CQ'><pre id='dP8CQ'><center id='dP8CQ'></center></pre></bdo></b><th id='dP8CQ'></th></span></q></dt></tr></i><div id='dP8CQ'><tfoot id='dP8CQ'></tfoot><dl id='dP8CQ'><fieldset id='dP8CQ'></fieldset></dl></div>

                      <bdo id='dP8CQ'></bdo><ul id='dP8CQ'></ul>
                      • <tfoot id='dP8CQ'></tfoot>

                        <small id='dP8CQ'></small><noframes id='dP8CQ'>

                          <tbody id='dP8CQ'></tbody>

                            <legend id='dP8CQ'><style id='dP8CQ'><dir id='dP8CQ'><q id='dP8CQ'></q></dir></style></legend>