Here is my situation: I have an app shell and have controller classes to 
load templates which have custom polymer elements in it. So far I load the 
template and add to the DOM and everything is work fine for first sight.
After the template contents are added to the DOM I try to access to the 
custom-element methods but I could not access to it. If I try to debug the 
code and run the important steps in console then I can acces to the element 
methods.

*My Element:*

    <link rel="import" href="../../components/polymer/polymer.html" />
    <dom-module is="app-login">
    <template>
        <style>
           :host { display: block; }
           :host.hide { display: none; }
        </style>
        <div> samle content </div>
    </template>
    <script>
    Polymer({
        is: 'app-login',
        run: function() {
            return new Promise(function(resolve, reject) {
                resolve({'id':0,'name':'user'});
            });
        }
    });
    </script>
    </dom-module>

*My Program:*

    // [...]

    // this works fine, I just add for better understanding
    getTemplate( templateName ) {
        return new Promise(function(resolve, reject)
        {
            fetch( 'templates/'+templateName+'.html' ).then(response => {
                document.getElementById('templates').innerHTML += response.
text();
                resolve(response);
            }).catch(error => { reject(error); });
        });
    };
    // [...]
    // this method called by the main program and cant't access to the 
element methods
    doLogin() {
        this.getTemplate('login').then(templateResponse => {
            let Login = document.querySelector('app-login'); // 
<app-login>...</app-login>
            Login.run(); // TypeError: Login.run is not a function
        });
    };
    // [...]

*templates/login.html:*

    <link rel="import" href="elements/app-login/app-login.html" />
    <app-login></app-login>

*Console debugging:*

    let Login = document.querySelector('app-login');
    //Return: <app-login>...</app-login>
    Login.run();
    //Return: Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: 
undefined}

I tried search for this but I could not find any relevant answer yet, 
somebody solved this issue in some way before? Did I make something just 
bad?

*Already tried:*
 - setTimeout (300ms) after adding element to the DOM » same result
 - adding _ to the method name (like paper elements methods) » same result
 - waiting for WebComponentsReady event after inserting the element into 
the DOM » event not fired, the program stopped

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/aedc791c-3e32-425e-b9ff-4cd6e71aac81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to