angular-location-update
Updates location path without reloading of controllerInstall
1bower install angular-location-update --save
or download or include hosted from github.io
````<script src="//anglibs.github.io/angular-location-update/angular-location-update.min.js"></script>
````2 Add module to your app: ```` angular.module('yourapp', 'ngLocationUpdate'); ````
Usage
```` $location.updatepath('/notes/1'); $location.updatepath('/notes/1/wysiwyg', true); ```` Parameters: 1. New path 1. Keep old path in browser history (By default it will be replaced by new one)When it's needed?
For example you have route/notes/new
which shows form for new note.In modern web app you may have no "Save" button - note created and saved to database once user made any change. Then you would like to change route to
/notes/1
showing to user, that here is URL of his new document.
Also if he will refresh page or go back and forward using browser buttons - he will see what he expects.FYI
Did you know, that you can easily change your URLsfrom
http://mysite.com/#/notes/1
to http://mysite.com/notes/1
For this: 1. Config app:
angular.module('your_app').config(function($locationProvider) { $locationProvider.html5Mode(true); });
2. Add in your HTML <base href="/">
More info: https://docs.angularjs.org/guide/$location