dotJEM / angular-routing

Enhanced state based routing for Angular applications!
https://dotjem.github.io/angular-routing/
MIT License
75 stars 9 forks source link

Make Parameters more accessible #48

Closed jeme closed 11 years ago

jeme commented 11 years ago

49 raises an issue around Refresh, where parameters will be less accessible, so it needs to be considered how we can make them more accessible when using refresh.

But beyond that, this is about restructuring the parameter object, and how it is passed around... Right now we have:

That leaves us without any options.

One solution would be to define a property for parameters directly on $state, like $state.params, or alternatively add a $stateParams value to the injector like UI-Router does, the later is ok but I feel that people will often end up including both the parameters and state service anyways, and so $stateParams over $state.params seems to add very little value, if any at all...

However, having to type params.all etc is tedious as well. so we need to redesign that part as well, but being able to filter out the different parameters in could be handy in some cases not to mention that optional and search parameters should be available... So changing to an implementation with reserved property names seems like a way to go, like so:

{
  // ['x'] -> Path or All ?? - Depending on the choice of the outer object, either `$all` or `$ goes away path`
  $all : {}, // -> Returns all parameters
  $path : {}, // -> Returns route parameters
  $search : {} // -> Returns search parameters
}
jeme commented 11 years ago

https://github.com/dotJEM/angular-routing/commit/16a6fac0b0ddacc76310e789071812599bc764c9