Refactor to allow re-use with $location service

Refactor to allow re-use with $location service when used inside controller code.
Merge pull request #1 from okigan/master

Refactor to allow re-use with $location service