javascript - Polymer: using element multiple times with different viewmodel -
i want create polymer element , use in multiple places different viewmodel
polymer element:
<polymer-element name="my-elem"> <template> <div>{{firstname}} {{lastname}}</div> </template> <script> polymer("my-elem", { ready: function() { this.firstname = "souvik"; this.lastname = "basu"; } }); </script> </polymer-element>
this works , shows name souvik basu
when used in html page. instead of hard coding firstname , lastname inside element, want show names of 2 persons while using element:
<my-elem></my-elem> // should show super man <my-elem></my-elem> // should show man
how can pass javascript objects these elements while using them?
just make 2 attributes. don't event need script tag
<my-elem firstname='wir' lastname='lez'></my-elem> <polymer-element name="my-elem" attributes='firstname lastname' noscript> <template><div>{{firstname}} {{lastname}}</div></template> </polymer-element>
Comments
Post a Comment