]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/extern/angular-location-update/README.md
webstaff: add angular-location-update dependency
[Evergreen.git] / Open-ILS / web / js / ui / default / staff / extern / angular-location-update / README.md
1 # angular-location-update
2
3 Updates location path without reloading of controller
4
5 ## Install
6
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
8 ````
9     <script src="//anglibs.github.io/angular-location-update/angular-location-update.min.js"></script>
10 ````
11
12 2 Add module to your app:
13 ````
14   angular.module('your_app', ['ngLocationUpdate']);
15 ````
16
17 ## Usage
18
19 ````
20 $location.update_path('/notes/1');
21 $location.update_path('/notes/1/wysiwyg', true);
22 ````
23 Parameters:
24  1. New path
25  1. Keep old path in browser history (By default it will be **replaced** by new one)
26
27 ## When it's needed?
28
29 For example you have route `/notes/new` which shows form for new note.
30
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.
34
35 ## FYI
36
37 Did you know, that you can easily change your URLs  
38
39 from `http://mysite.com/#/notes/1` to `http://mysite.com/notes/1`
40
41 For this: 
42  1. Config app: `angular.module('your_app').config(function($locationProvider) { $locationProvider.html5Mode(true); });`
43  2. Add in your HTML `<base href="/">`
44
45 More info: https://docs.angularjs.org/guide/$location 
46
47 ## Credits
48
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