Change router so route can be a callback function#2834
Change router so route can be a callback function#2834richardcrichardc wants to merge 1 commit intoangular:masterfrom richardcrichardc:routeFunction
Conversation
PR Checklist (Minor Feature)
|
|
Re: PR Checklist
This is not ready to merge. At this stage I am just soliciting feedback. I'm not trying to be obtuse or anything, but there is not much point spending the time tidying this up if it is not going to be merged, otherwise it's just busy work. I am more than happy to have a discussion about the proposed functionality. |
|
OK but you could sign the CLA anyway for good measure :-) |
|
Yes. I signed that electronically about three months ago, when I submitted On 18 July 2013 01:40, Pete Bacon Darwin notifications@github.com wrote:
|
|
@richardcrichardc: @chirayuk and I did a quick review and like the functionality. Could you flesh this out further and add documentation and tests so we can review for merging? And no coffeescript in examples please! :) |
|
OK. I've merged the changes with the master from this morning, added some docs and unit tests. It's on a new branch here: https://github.com/richardcrichardc/angular.js/tree/routeFunction2. I suspect if I merge the changes with my original branch it will show all changes since 1.1.4. here. |
|
A fine example of how not to use github. Updated patch here: #3359 |
Thinking about feedback from #2571 which I submitted a few weeks ago, here is another idea for making routing extensible. It has the benefit of allowing you to use the existing router for routes it is good at.
The premise is that no router is likely to meet everyone's requirements, so make it plugable. It turns out it already is. You can register another service with the name '$router'. However, I would argue that that is a lot of work when the current router almost does what you want. It turns out other routers exist, but I have not found one that meets my requirements.
This pull requests allows you to pass a callback function as a route. Below is an example. It is a simplification of what I need to do, in fact cat is a path like x/y/ or x/y/123 so more parsing is done. Excuse the coffescript:
Another feature not shown here is that params and search can be updated by the route function - though I have not tested this for search.
Any feedback would be appreciated. Let me know if this is likely to be merged, then I can add documentation and do more thorough testing.
It would also be helpful to get some idea whether updating the router is a priority of the core developers of angular and if so what they see as key priorities.