Polymer, how to format a URL string w/ a variable -
i want binding url string this:
like not work. should do?
<dom-module id="list-view"> <template id="app" testattr$="{{value}}" > <iron-list id="list" items="{{data}}" as="item"> <template> <a href="{{item.id}}" > <span>[[item.name]]</span> </a> </template> </iron-list> </template> <script> polymer({ is: 'list-view', ready: function() { var _self = this; $.get('data/persons.json',function(data){ _self.data = }); }); }); </script> </dom-module>
i use iron-list element repeat data list. object --> [{"id":"001","name":"adisak"},{"id":"002","name":"adisak2"},{"id":"003","name":"adisak3"}] use iron-list binding data in list of element
you can compute url method, this:
<dom-module id="list-view"> <template id="app" testattr$="{{value}}" > <iron-list id="list" items="{{data}}" as="item"> <template> <a href="{{_computeurl(item.id)}}" > <span>[[item.name]]</span> </a> </template> </iron-list> </template> <script> polymer({ is: 'list-view', ready: function() { var _self = this; $.get('data/persons.json',function(data){ _self.data = data; }); }, _computeurl: function(id) { return '/myurl/' + id; } }); </script>
Comments
Post a Comment