Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

feat(ngRoute): add named routes #7427

Closed
wants to merge 1 commit into from
Closed

Conversation

stakach
Copy link

@stakach stakach commented May 11, 2014

Request Type: feature

How to reproduce:

Component(s): ngRoute

Impact: medium

Complexity: medium

This issue is related to:

Detailed Description:

Routes are defined in the same way as regular AngularJS routes except it is possible to supply a name for a route.
If a route is requested it provides a promise that is resolved once navigation is complete, or rejected if another route was navigated to in the same digest.

Links can be defined using the ngGoto directive and should be used instead of ngHref as only name need be used instead of the entire path. It is also possible to effect only a particular named group in the path without updating the rest. For instance:

if you had two routes: /:user/links and /:user/pictures you could link to pictures like: <a ng-goto="pictures">pictures</a> and it would automatically pick up the user you are looking at and link to their pictures (if the current path was /steve/links then the href of the link above would be generated /steve/pictures)

Links or other DOM elements that define ng-goto also use the ng-click directive to enact the route change, thus supporting ngTouch if it is included and also filling out the href if a link element.

Would resolve:

Other Comments:

Named routes provide helper functions for scripted route changes and partial route updating,
components may update specified named groups in a route without knowing the semantics of a
route. A directive, ngGoto, is provided for binding routes to DOM elements such as the A tag.

It is 100% backwards compatible with the existing routing system so could be added in a point release.

Named routes provide helper functions for scripted route changes and partial route updating,
components may update specified named groups in a route without knowning the semantics of a
route. A directive, ngGoto, is provided for binding routes to DOM elements such as the A tag.
@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#7427)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@mary-poppins
Copy link

I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let us know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@stakach stakach added cla: no and removed cla: yes labels May 12, 2014
@stakach
Copy link
Author

stakach commented May 12, 2014

CLA Signed (key=p9iNysFj43uDtUPeRrKvGNQ)
Although I had previously signed it under a different alias for the same gmail account.

@stakach
Copy link
Author

stakach commented May 14, 2014

ping @IgorMinar @caitp is this a feature you would be willing to consider? I noticed that ng-link is on the table for routing v2, happy to rename ng-goto. Any feedback would be much appreciated.

@caitp
Copy link
Contributor

caitp commented May 14, 2014

Is this different from ui-router somehow? It sounds very ui-router, from reading the description

@stakach
Copy link
Author

stakach commented May 14, 2014

Quite different. Much simpler too.
Effectively provides helper functions for scripting route changes / partial route changes, promises to handle success or failure of that route change and a directive to support mobile (via ngTouch), and build hrefs for links. Especially useful for partial route changes, updating a single named group in the route

It differs from ui-router as it doesn't try to do anything special with views. i.e. for sub view updates ng-switch could be used against a route param.

The main aim was to add a lot of powerful functionality without breaking the existing route system, as you can see via the diff.


// Defines a routes path based on the params (does not include search params)
$route.pathTo[routeName] = function(params) {
return interpolate(path.replace(/\*|\?/g, ''), angular.extend({}, $routeParams, params));
Copy link
Author

Choose a reason for hiding this comment

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

Need to update this. The regex should match the one on line 459

@caitp
Copy link
Contributor

caitp commented May 14, 2014

@stakach, Obviously I can't speak for Igor, but the thing is, we were talking about limiting the number of new features going into 1.3 so that we can focus on the next iteration of the framework, so I feel like this is probably not going to ship, for that reason.

I am also not sure if I can really extend a full invitation to work on v2 just yet, since it's largely in the prototyping phase, and the codebases aren't very stable yet. It sounds like you've looked at the router design document, and might want to help work on prototyping the router, in which case, you might want to get in touch with @EisenbergEffect or @btford or @tbosch. But again, I don't know how feasible it is to help much with that (I haven't been able to contribute much with it, or even keep up with it, for the most part), because of the unstable codebase, and the fact that more people working on it just increases that instability.

But, from my perspective, it doesn't hurt to have more people dogfooding it and figuring out what works and doesn't work, so personally I'd say go for it, and see what you can do with it. So I'd say get in touch with Rob and see if you can find some problems in the prototype that hurt usability, and highlight the things you like with it.

@EisenbergEffect
Copy link

Hey @stakach I'd love to talk about router ideas. My email is available through my github profile. Drop me a line and lets start a conversation.

@stakach
Copy link
Author

stakach commented May 14, 2014

Thank you for the quick response @caitp
@EisenbergEffect I'll be in contact.

@tbosch tbosch self-assigned this May 21, 2014
@tbosch
Copy link
Contributor

tbosch commented May 21, 2014

Closing this. Please contribute to the router in Angular v2 via @EisenbergEffect or use ui-router instead.

@tbosch tbosch closed this May 21, 2014
@tbosch tbosch removed their assignment May 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants