-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat($routeProvider): Allow using functions as template params in 'when' #1524
Conversation
@IgorMinar , is there anything I should do to get this PR into consideration? |
@pkozlowski-opensource . Igor seems to be MIA. Is this PR ok? |
@lrlopez don't worry, he is not :-) As for your PR - it looks good from what I can tell by very quickly looking at it. Having said this there are multiple PRs touching the routing system and we would like to look at them as a whole since some of them are a bit conflicting. |
@pkozlowski-opensource, thanks for the feedback. I've been reviewing some of the PRs related to the routing system and I think this particular one is fully compatible with them. Anyway, I also think that routing could be further improved with lot of useful features (i.e. states-charts, subviews, etc). Why don't we create an issue or a thread in the mailing list to throw in any ideas on this respect? We could enumerate the weakness in the current system and propose different potential solutions to them, along with their respective pro&cons and use cases. May be we could get one core team member assigned into it to coordinate the discussion. Of course, maintaining backward compatibility could be a requirement if the AngularJS team thinks so. Do you like the idea? |
@lrlopez Yes, I think that discussing this further is inevitable. As you've noticed there are several PRs touching the routing system (and another bunch of open issues). I think that it would be really beneficial to further discuss the requirements for the improved routing as well as the syntax that should be supported. As soon as this is settled the implementation should be easy :-) So yes, if you could post a kick-off thread on the mailing list (linking to all the open PRs) it would be great. Maybe people will come to the same conclusions and agree on the needs / syntax. |
Posted! I've created a thread for each aspect it could be enhanced about AngularJS routing. https://groups.google.com/forum/?hl=en&fromgroups=#!topic/angular/dTw2PIpGqsk |
We are discussing how to enhance parameter specification here: https://groups.google.com/forum/#!topicsearchin/angular/embedded/angular/w-LPkyrBWqY Can you help us? |
Thanks for your contribution! In order for us to be able to accept it, we ask you to sign our CLA (contributor's license agreement). CLA is important for us to be able to avoid legal troubles down the road. For individuals (a simple click-through form): For corporations (print, sign and scan+email, fax or mail): |
@mhevery |
MERGED |
How difficult would it be to add this support for directives? |
Hmmm.... I don't think it would be a problem... I'll try to create a new PR tomorrow |
Another good change could be to be able to supply function to templaceUrl. I suppose that would not be a big change... |
Thanks, Luis. |
I agree with you that it would be a powerful enhancement... But I fear it will take some more time to implement because it is not as trivial as I thought. First of all, I need to think what parameters should be associated with the called function (take into account that we are constrained to the info available at compile time). I'll keep working to have the PR ready ASAP. |
Well, PR #1849 ready to go! |
Ping @pkozlowski-opensource @IgorMinar @mhevery @vojtajina Sorry for bringing your attention in such a inconvenient way, but I'd rather not pollute the issues queue. I don't know if you are aware that a task group has been formed under the angular-ui project to discuss enhancing the AngularJS routing in a backward compatible way. We would really like someone from then AngularJS team to join us in order to, eventually, embed the changes into the main codebase so we can all benefit. Pawel requested something similar to this two months ago in this same PR. What do you think? Most of the discussion is here: https://github.com/angular-ui/router/issues/1 https://github.com/angular-ui/router/issues/7 Thank you in advance! |
Has this been merged? If yes, the docs don't talk about it at http://docs.angularjs.org/api/ng.$routeProvider |
Yes, it has. The new functionality is available in 1.1.2, which is considered unstable. I think docs are built from the stable branch (1.0.4) so that could explain the missing piece of info from the docs. |
This pull-request allows using custom functions when assigning templates in $routeProvider.when() method.
The new functionality could be used to generate templates on the fly based on the route parameters. Also, if used in templateUrl, the particular template URL that gets loaded can be customized.
P.S. I've just signed the CLA.