| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 @license | 2 @license |
| 3 Copyright (c) 2016 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2016 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --><html><head><link rel="import" href="../polymer/polymer.html"> | 9 --><html><head><link rel="import" href="../polymer/polymer.html"> |
| 10 <link rel="import" href="../iron-location/iron-location.html"> | 10 <link rel="import" href="../iron-location/iron-location.html"> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 Example Usage: | 30 Example Usage: |
| 31 | 31 |
| 32 <app-location route="{{route}}"></app-location> | 32 <app-location route="{{route}}"></app-location> |
| 33 <app-route route="{{route}}" pattern="/:page" data="{{data}}"></app-route> | 33 <app-route route="{{route}}" pattern="/:page" data="{{data}}"></app-route> |
| 34 | 34 |
| 35 As you can see above, the `app-location` element produces a `route` and that | 35 As you can see above, the `app-location` element produces a `route` and that |
| 36 property is then bound into the `app-route` element. The bindings are two- | 36 property is then bound into the `app-route` element. The bindings are two- |
| 37 directional, so when changes to the `route` object occur within `app-route`, | 37 directional, so when changes to the `route` object occur within `app-route`, |
| 38 they automatically reflect back to the global location. | 38 they automatically reflect back to the global location. |
| 39 | 39 |
| 40 A `app-location` can be configured to use the hash part of a URL as the | 40 ### Hashes vs Paths |
| 41 canonical source for path information. | |
| 42 | 41 |
| 43 Example: | 42 By default `app-location` routes using the pathname portion of the URL. This has |
| 43 broad browser support but it does require cooperation of the backend server. An |
| 44 `app-location` can be configured to use the hash part of a URL instead using |
| 45 the `use-hash-as-path` attribute, like so: |
| 44 | 46 |
| 45 <app-location route="{{route}}" use-hash-as-path></app-location> | 47 <app-location route="{{route}}" use-hash-as-path></app-location> |
| 46 | 48 |
| 49 ### Integrating with other routing code |
| 50 |
| 51 There is no standard event that is fired when window.location is modified. |
| 52 `app-location` fires a `location-changed` event on `window` when it updates the |
| 53 location. It also listens for that same event, and re-reads the URL when it's |
| 54 fired. This makes it very easy to interop with other routing code. |
| 55 |
| 47 @element app-location | 56 @element app-location |
| 48 @demo demo/index.html | 57 @demo demo/index.html |
| 49 --> | 58 --> |
| 50 </head><body><dom-module id="app-location"> | 59 </head><body><dom-module id="app-location"> |
| 51 <template> | 60 <template> |
| 52 <iron-location path="{{__path}}" query="{{__query}}" hash="{{__hash}}" url-s
pace-regex="{{urlSpaceRegex}}"> | 61 <iron-location path="{{__path}}" query="{{__query}}" hash="{{__hash}}" url-s
pace-regex="{{urlSpaceRegex}}"> |
| 53 </iron-location> | 62 </iron-location> |
| 54 <iron-query-params params-string="{{__query}}" params-object="{{queryParams}
}"> | 63 <iron-query-params params-string="{{__query}}" params-object="{{queryParams}
}"> |
| 55 </iron-query-params> | 64 </iron-query-params> |
| 56 </template> | 65 </template> |
| 57 </dom-module> | 66 </dom-module> |
| 58 <script src="app-location-extracted.js"></script></body></html> | 67 <script src="app-location-extracted.js"></script></body></html> |
| OLD | NEW |