1 # angular-location-update
3 Updates location path without reloading of controller
7 1 `bower install angular-location-update --save` or [download](http://anglibs.github.io/angular-location-update/angular-location-update.min.js) or include hosted from github.io
9 <script src="//anglibs.github.io/angular-location-update/angular-location-update.min.js"></script>
12 2 Add module to your app:
14 angular.module('your_app', ['ngLocationUpdate']);
20 $location.update_path('/notes/1');
21 $location.update_path('/notes/1/wysiwyg', true);
25 1. Keep old path in browser history (By default it will be **replaced** by new one)
29 For example you have route `/notes/new` which shows form for new note.
31 In modern web app you may have no "Save" button - note created and saved to database once user made any change.
32 Then you would like to change route to `/notes/1` showing to user, that here is URL of his new document.
33 Also if he will refresh page or go back and forward using browser buttons - he will see what he expects.
37 Did you know, that you can easily change your URLs
39 from `http://mysite.com/#/notes/1` to `http://mysite.com/notes/1`
42 1. Config app: `angular.module('your_app').config(function($locationProvider) { $locationProvider.html5Mode(true); });`
43 2. Add in your HTML `<base href="/">`
45 More info: https://docs.angularjs.org/guide/$location
49 Solution invented by guys in these threads:
50 1. https://github.com/angular/angular.js/issues/1699
51 1. https://github.com/angular-ui/ui-router/issues/427
52 1. http://stackoverflow.com/questions/14974271/can-you-change-a-path-without-reloading-the-controller-in-angularjs