Polymer core-selector - using the selected data -
I am creating a custom element to read files in a given directory (such as INI from / config directory Files) and display them as a wrapped list in a main selector then the user can then select a file from the list. All the work, except reading selected data, seems to be a junky code:
& lt; Div & gt; & Lt; Core-selector on-core-active = {{getFile selected]} selected = "" & gt; & Lt; Template repeat = "{{files in files}}" & gt; & Lt; RNC-commandfilelist & gt; & Lt; Span class = "rnc-fileindex" & gt; {{File.index}} & lt; / Span & gt; & Lt; Span class = "rnc-filename" & gt; {{File.commandFileName}} & lt; / Span & gt; & Lt; / RNC-commandfilelist & gt; & Lt; / Template & gt; & Lt; / Core-selector & gt; & Lt; / Div & gt; & Lt; / Template & gt; & Lt; Script & gt; Polymer ('rnc-getscaffoldini', {matchstring: ".ini", configuration directory: "configuration", getFile selected: function (e, extension, sender) {var file selected = descriptions.imetems child [1] .intext; console .log (file selected); var full path = this.configurationdirectory + "/" + file selected, this .setupbrit ('selected filename', file selected); this.setAttribute ('selectedfullpathname', fullPath);}}); & Lt; / Script & gt;
Code line:
var file selected = details. ITEM Children [1] .intertext;
The selected filename is fine. Is there a better way to get back to the selected data field?
published by selected model
core-selector
Property represents the selected data model. Repeated syntax here repeat = "{{files in files}}" & gt;
means that each item contains a data model in which there is a property called scope data plus file
. This means for each item, the selected file is stored in the selector as selectedModel.file
. You can use the binding to access the data.
So, if you do this:
& lt; Chooser-selector selected = Module = "{{selectedModel}}" & gt;
then it may be:
changed the selected model: function () {// This. The selected model.file refers to that particular file Fuiw, you can also create it like this: & lt; Template repeat = "{{files}}" & gt; & Lt; RNC-commandfilelist & gt; & Lt; Span class = "rnc-fileindex" & gt; {{Index}} & lt; / Span & gt;
Due to the various recurrence syntax, the data model is now only a file record, therefore:
Then you can do the following:
changed the selected file: function () {// it. The selected file refers to the selected file}
Comments
Post a Comment