extract url parsing / composing into reusable service
something like this:
compose(/path/:verb, {verb:'greet', salutation:'Hello'});
// results in URL /path/greet?salutation=Hello
$route does similar (reverse) stuff when parsing an url into params...
+1 :)
+1
+1
+1
This is a nice idea, would it be a good idea to expose this service on $location and also allow parsing of url strings without actually changing the location (if you pull one from an iframe for example)?
+1
+1
+1 would love to see something as powerful as http://medialize.github.com/URI.js/ rolled into $location
+1
+1
+1, one of my template needs this right now to massage some urls
+1
+1
I would like to have this. It can't be difficult to implement. $resource has the same system (Route.setUrlParams).
Made some code to solve this problem. It would be better when this was native angular code.
https://github.com/eonlepapillon/parametrizedLocation
:+1:
+1
I have been using https://github.com/fxa/uritemplate-js
uses like,
template = UriTemplate.parse('{?query*})'; template.expand({query: {first: 1, second: 2}}); --> "?first=1&second=2"
it is based on RFC6570
Another popular one is https://github.com/medialize/URI.js better docs, and option http://medialize.github.io/URI.js/
the only issue is the RFC uses {id} format, and angular :id. That's actually ok, depends on how you represent your string url. You can use it in route registration too like
$routeProvider .when(UriTemplate.parse('/path/{verb}).parse({}) ...
`
+1
1+