Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get query string in Polymer

Is there anyway how can I get query string in Polymer?

http://localhost:8080/search?param=ppshein

I want to get search?param=ppshein or param=ppshein in Polymer.

I've tried to get query string in app-route but it display nothing.

<app-route
    route="[[route]]"
    pattern="/:id"
    data="{{routeData}}"></app-route>

[[routeData.id]] **
like image 784
PPShein Avatar asked Nov 18 '16 03:11

PPShein


People also ask

What is my query string?

A query string is the portion of a URL where data is passed to a web application and/or back-end database. The reason we need query strings is that the HTTP protocol is stateless by design. For a website to be anything more than a brochure, you need to maintain state (store data).

What is query string with example?

A query string commonly includes fields added to a base URL by a Web browser or other client application, for example as part of an HTML, choosing the appearance of a page, or jumping to positions in multimedia content.

What is query string in API?

Query string parameters are useful tools when accessing information from APIs. In the most basic cases, using the correct query strings can limit the number of responses returned while others have the ability to embed multiple tables and databases with one endpoint.


1 Answers

You could use <app-location>.queryParams:

<app-location route="{{route}}" query-params="{{queryParams}}"></app-location>

queryParams is an object containing key/value pairs of the parsed query parameters. Given http://localhost:8080/search?param=ppshein, queryParams would be:

{
  param: 'ppshein'
}
like image 77
tony19 Avatar answered Oct 19 '22 05:10

tony19