Get params from url. A non-binding element
npm install @elifent/url-params
npm install @elifent/url-params
`
In an html file
`
pattern="/path/to/page/:data/:to/:parse"
data="{{params}}"
>
Value in data is {{params.data}}
Value in to is {{params.to}}
Value in parse is {{params.parse}}
`
In polymer 3 element
`
import {PolymerElement, html} from '@polymer/polymer';
import '@elifent/url-params/url-params.js';
class SampleElement extends PolymerElement {
static get template() {
return html
;
}
}
customElements.define('sample-element', SampleElement);
`
Other methods
Alternatively you can read all params from a GET request. To do it use pattern as ?
`
import {PolymerElement, html} from '@polymer/polymer';
import '@elifent/url-params/url-params.js';
class SampleElement extends PolymerElement {
static get template() {
return html
;
}
}
customElements.define('sample-element', SampleElement);
`
In this case if your url is path/to/page?data=a&to=b&parse=c then you will be able to get params.data as a.
Contributing
Running demo locally
$3
`
git clone https://github.com/elifent/url-params
cd url-params
npm install
npm install -g polymer-cli
`
$3
`
polymer serve --npm
open http://127.0.0.1:/demo/index.html?name=George&age=30&sex=male
``