Hi Marc, Agreed that this would be useful, and it's something we've had to implement ourselves in a couple of places in our app. The thing is that Angular itself never really does this particular operation of plugging a set of params into a known route string. What it does is compare the URL you're trying to load against a regular expression it's compiled for each registered route, and if there's a match, pulls out the params from the match based on the keys (wildcards) from the original route string. You can see this if you look at $route.routes['/path/:to/:route?'].regexp and .keys.
There is some (non-exposed) interpolation code specifically for redirects, but it doesn't handle the full route syntax with ? and *. Kevin On Mon, Oct 27, 2014 at 10:03 AM, Marc Fallows <[email protected]> wrote: > My next step is filing an issue on github to see if this is something they > would consider. > > My first step was posting here to ensure that there wasn't an existing way > to do this. I thought I missed it in the AngularJS ngRoute documentation. > > The thread keeps diverging from the original question of if the > interpolation is exposed in ngRoute. I'm going to assume "no" and I'll look > to continue this on github. > > Thanks, > > Marc Fallows > [email protected] > > On Mon, Oct 27, 2014 at 1:12 PM, Sander Elias <[email protected]> > wrote: > >> Hi Marc, >> >> I could also write my own forEach and isUndefined in plain javascript. >>> But since AngularJS already does this they expose it through an API, and I >>> don't have to write it. >>> >> The core team has on a number of occasions put out, that they where >> unhappy with this decision. They do regret putting those utility functions >> in the core. >> and for that matter you don't need to program your own forEach >> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach>, >> it's available in ES5. As goes for quite some other utility functions. >> >> >> >>> I want to pass one of the paths that I original passed to >>> $routeProvider.when(path, {...}) along with an object of parameters and get >>> a resulting URL which I could set in $location.path(). >>> >> >> Well, If you really want something like this in AngualrJS, file issue on >> github. If you accompany it with an Pull Request, with fully tested code, >> there is a fair change >> it will get included in one of the next 1.3.x versions. >> >> Regards >> Sander >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "AngularJS" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/angular/bEX5Ateee98/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/angular. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
