Can ui-router handle multiple parameters in AngularJS?

末鹿安然 提交于 2019-12-13 04:08:32

问题


I have an app that is currently built to have a static base URL with a parameter at the end. I would like to instead have the base URL default to one vaule, but have the ability to built routes based on several options. So for now its set up as:

  .state('ball', {
    parent: 'ballLayout',
    url: '/ball/{urlName}',
    views: {
      'cube.head': {
        templateUrl: 'partials/views/ball.head.html',
        controller: 'BallCtrl'
      }
    }
  });

The static ball value is what I'd like to change. Basically I'd like to have an optional list of incoming URLs that would work, but when nothing is present it defaults to ball. So for instance:

ball/title-of-page

bat/title-of-page

basket/title-of-page

beast/title-of-page

These would all work, and when constructing the URL it would default to ball/

Is something like this possible? How would one go about implementation.


回答1:


I dont think what I'm asking here can actually be done without having issues with other parameters. Instead Im asking a new question about Regex from incoming links to reroute to my angular URL.



来源:https://stackoverflow.com/questions/23959956/can-ui-router-handle-multiple-parameters-in-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!