Polymer 2.0, property access

34 views
Skip to first unread message

hell...@googlemail.com

unread,
Jul 17, 2017, 5:17:55 AM7/17/17
to Polymer
Hi,

I have a quite simple component that presents a login screen with native input elements. There is a button which calls "logIn()" on click. If I print out the values of username/password, both are undefined. I tried everything, but nothing works. 

<dom-module id="dashboard-login">
   
<template>
       
<style>
           
:host {
               
display: block;
           
}
       
</style>
       
<h2>Hello [[prop1]], authenticated=[[authenticated]]!</h2>
       
<div>
           
<div><label>Username: </label><input value="{{username::input}}"></input></div>
           
<div><label>Password: </label><input type="password" value="{{password::input}}"></input></div>
           
<div>
               
<button onclick="{{logIn}}" raised>Log in</button>
           
</div>
       
</div>
   
</template>

   
<script>
       
/**
         * `dashboard-login`
         * Login to Dashboard
         *
         * @customElement
         * @polymer
         * @demo demo/index.html
         */
        class DashboardLogin extends Polymer.Element {
           
constructor() {
               
super();
           
}

           
static get is() {
               
return 'dashboard-login';
           
}

           
static get properties() {
               
return {
                   
prop1: {
                       
type: String,
                       
value: 'dashboard-login'
                    },
                   
username: {
                       
type: String,
                       
value: 'username'
                    },
                   
password: {
                       
type: String,
                       
value: 'password'
                    },
                   
authenticated: {
                       
type: Boolean,
                       
value: false
                    }

               
};
           
}


           
logIn() {
               
console.log("username="+this.username+", password="+this.password);
           
}

       
}

       
window.customElements.define(DashboardLogin.is, DashboardLogin);
   
</script>


abhishek gupta

unread,
Jul 17, 2017, 7:30:15 AM7/17/17
to Polymer
Have you tried using this ($=).
 
Reply all
Reply to author
Forward
0 new messages