首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Angular 1 - UI-Router - 动态声明?

Angular 1 - UI-Router - 动态声明?
EN

Stack Overflow用户
提问于 2018-05-29 05:25:34
回答 1查看 0关注 0票数 0

我有一个很长的州名单:

代码语言:javascript
复制
  export default ($stateProvider) => {
      'ngInject'
      $stateProvider
        .state({
          name: 'agent.contact',
          url: '/contact',
          abstract: true,
          component: 'agentContact'
        })
        .state({
          name: 'agent.contact.list',
          url: '/list',
          component: 'agentContactListPage',
          data: {
            title: 'agent.commonLabel.myContacts'
          },
          resolve: {
            preferences: (ContactService) => ContactService.getContactPreferences()
          }
        })
       .state({
         name: 'agent.contact.list.overlay',
         abstract: true,
         data: {
           skipFooter: true,
           cancelState: 'agent.contact.list'
         },
         views: {
           'overlay@agent.': {
             component: 'overlayContent'
           }
          }
        })
        .state({
          name: 'agent.contact.create',
          url: '/create',
          abstract: true,
          data: {
            skipSubmenu: true,
          },
          resolve: {
            contact: ($stateParams, ContactService) => ContactService.getNewContact($stateParams.type)
          }
        })
    }

我正在寻找一个解决方案来动态化各州的声明,同时考虑到所有州都与agent.contact相关联。

我可以利用哪些解决方案?

EN

回答 1

Stack Overflow用户

发布于 2018-05-29 14:59:34

这是抽象状态的要点。

代码语言:javascript
复制
  $stateProvider
    .state({
      name: 'agent.contact',
      url: '/contact',
      abstract: true,
      component: 'agentContact',
      resolve: {
        preferences: (ContactService) => ContactService.getContactPreferences()
      },
      children: [{
         name: 'list',
         url: '/list',
         component: 'agentContactListPage',
         data: {
            title: 'agent.commonLabel.myContacts'
         }
      }]
    })
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100004579

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档