Can ui-router handle multiple parameters in Angula

2019-09-15 08:30发布

问题:

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.