Add $location service
ceoaliongroo opened this issue · comments
There are some benefits If use the module use $location instead window.location
http://docs.angularjs.org/guide/$location
Yes, the reason we didn't use it was because at the time we need to call location
(in .config()
) it isn't available. If you know how to make it work, please let us know.
We've changed things since then I remember now. It might be possible, will try it out! Hopefully it will allow unit-testing of that part. Busy creating demos atm.
This issue can be the request for a pure $location refactor. If you do just the $location bit with the tests you have it would be awesome. Please sync down the latest code though, just did some big updates.
Two things to think about is routing.
- Query parameters like
apimock=true
don't sit inwindow.location.search
butwindow.location.hash
. Need to verify that this works with $location. - When using
ngRoute
it doesn't do a page refresh when adding?apimock=true
so the parameter isn't picked up. Need to make sure routes update the mock flag. See here for a sample where this breaks.
@seriema about:
- I understood the explanation, but still is difficult see the issue or the new feature that you propourse without a code example.
Could you create a fail spec in the test?
Thanks
- You could try to add reloadOnSearch=false in the route
$routeProvider
.when('/', {
templateUrl: 'views/movies-table-list.html',
controller: 'MoviesCtrl',
reloadOnSearch: false
})
.otherwise({
redirectTo: '/movies/list/'
});
});
Could you give access to the demo code?
All the best...
-
We don't need to worry about that anymore. It seems to be working with $location.
-
Interesting! Two issues with that though. It would require ngRoute (we want to minimize dependencies) and it seems to be set on a per-url-basis (we need something generic).
The demo code is in the gh-pages-dev
branch. Thinking about moving them here to a /docs
folder or something.