Search code examples
javascriptautocompletepolymer-1.0paper-elements

Polymer: paper-autocomplete set value


I have a paper-autocomplete element as follows inside a <paper-card>

<paper-autocomplete label="Select HWName" 
                    id="HWName" 
                    on-autocomplete-selected="onDeviceSelect" 
                    no-label-float="true"></paper-autocomplete> 

in a given html file. I am accessing this from another file as follows

var hwName = document.querySelector("#HWName");

I need to be able to set some value in its input area on refresh, which i've remembered using localStorage API. I tried using

 hwName.value = "test" 
         or 
 hwName.label = "test" 

but it doesn't work. Even tried using setOption(option) as described here but doesn't work.

Is it possible to show some value on the paper-autocomplete element? I don't want to type, it should just set the last value.


Solution

  • You need to set text property of paper-autocomplete.

    So your code will be like

     hwName.text = "test"