Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to add optional parameters #186

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jlramosr
Copy link

@jlramosr jlramosr commented Mar 16, 2017

We have the possibility to add optional parameters on the pattern attribute with the ? character at the end.
In this example:

    <app-route
      active="{{active}}"
      route="{{route}}"
      pattern="/client/:id?"
      data="{{routeData}}"
      tail="{{subroute}}"></app-route>

The path /client matches the route, setting routeData.id to undefined and active to true. If pattern would be /client/:id, this path wouldn't matches the route. With the pattern of the example above, the path /client/c123 also matches the route, with routeData.id equal to c123.

A more complicated example would be the same app-route element with pattern attribute pattern="/client/:id?/:action?". The paths /client, /client/, /client/c123, /client/123/overview also matches the route. Supossing second path (/client/), routeData would be {'id': '', 'action': undefined}

This feature also works with fixed patterns without parameters (i.e. pattern="/client/list?").

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@jlramosr jlramosr changed the title posibility to add optional parameters possibility to add optional parameters Mar 16, 2017
Copy link

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be really cool! Could you add tests to verify that this is working as intended?

@jlramosr
Copy link
Author

jlramosr commented Mar 16, 2017 via email

@googlebot
Copy link

CLAs look good, thanks!

@jlramosr
Copy link
Author

jlramosr commented Mar 16, 2017 via email

@jlramosr jlramosr changed the title possibility to add optional parameters Possibility to add optional parameters Mar 17, 2017
@Oupsla
Copy link

Oupsla commented Jul 4, 2017

Any news about this feature ?

@ggirard07
Copy link

Optional parameters will be so cool and really help the routing process.
Any news on whether this PR can be accepted?

Copy link

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you accidently reverted some configuration which broke the Travis CI build

test/index.html Outdated
'app-location.html',
'test-observer-app.html',
'test-app-example-1.html',
'app-route-optional-params.html'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the changes to the test configuration to make sure we do not regress.

Revert changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants