Polymer: how to dynamically import an element

Asked By: Anonymous

Can anyone tell me how I could import an element depending on the value of a Polymer attribute?
I thought I could use data binding but… It’s not working. Is it possible to import an element dynamically?

code exemple here:

<link rel="import" href="app-window/{{name}}-app.html"> 
//This was my first idea (obviously doesn't work)


<polymer-element name="window-base" attributes="name" >
    <template>
        <link rel="stylesheet" href="window-base.css">
        <section id="app">
            <!--here will go the instance-->
        </section>
    </template>
    <script>
        Polymer('window-base', {
            name: "Finder",
            ready: function () {
                this.instanceApp();
            },
            instanceApp: function () {
            //this depends on the import made
                var app=document.createElement(this.name + "-app");
                this.$.app.appendChild(app);    
            }
        });
    </script>
</polymer-element>

Thanks!


Solution

Answered By: Anonymous

according to the Polymer 1.0 migration guide:

The global Polymer.import function is replaced by importHref. The new
method can be invoked from an element as this.importHref. Outside an
element, it can be called as as Polymer.Base.importHref.

So…

this.importHref(["yourComponent.html"], function() {})

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno