method of writing polymer
Answers
Answered by
0
To add an instance method to your element, just add a method on the element's prototype.
Polymer({ is: 'cat-element', _says: 'meow', speak: function() { console.log(this._says); } });
You can invoke the method on any instance of your element.
var cat1 = document.querySelector('cat-element'); cat1.speak(); var cat2 = document.createElement('cat-element'); cat2.speak();
Polymer({ is: 'cat-element', _says: 'meow', speak: function() { console.log(this._says); } });
You can invoke the method on any instance of your element.
var cat1 = document.querySelector('cat-element'); cat1.speak(); var cat2 = document.createElement('cat-element'); cat2.speak();
Similar questions