Polymer iron-ajax can't load data to control

153 views
Skip to first unread message

Fasasi Faiz

unread,
Sep 15, 2015, 12:40:05 PM9/15/15
to Polymer
Please help me out! I was unable to load data from my "data.json" file into my polymer controls
=====================================================================


<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/iron-ajax/iron-ajax.html">

<dom-module id="list-binding">
  <style></style>
  
 <template is="dom-bind">
     
     <iron-ajax 
        auto
        url="data.json"
        handle-as="json"
        last-response="{{data}}">
     </iron-ajax>
     
     <!--Binding from API-->
     <div class="list">
        <template is="dom-repeat" items="{{data}}">
         <paper-icon-item class="listItems">
          <img class="avatar blue" item-icon src="{{item.image}}">
            <paper-item-body two-line>
                <div class="title">{{item.title}}</div>
                <div secondary>{{item.description}}</div>
            </paper-item-body>
        </paper-icon-item>
        </template>
    </div>
  </template>
    
<script>
    
  Polymer({
    is: "list-binding",,
    ready: function() 
        
      }
  });
      
</script>
    
</dom-module>

Daniel Llewellyn

unread,
Sep 15, 2015, 12:46:06 PM9/15/15
to Polymer
I spot a couple problems straight-off. They're shown inline.

On Tuesday, 15 September 2015 17:40:05 UTC+1, Fasasi Faiz wrote:
Please help me out! I was unable to load data from my "data.json" file into my polymer controls
=====================================================================


<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/iron-ajax/iron-ajax.html">

<dom-module id="list-binding">
  <style></style>
  
 <template is="dom-bind">

remove is="dom-bind" - that is used for anonymous templates.
     
     <iron-ajax 
        auto
        url="data.json"
        handle-as="json"
        last-response="{{data}}">
     </iron-ajax>
     
     <!--Binding from API-->
     <div class="list">
        <template is="dom-repeat" items="{{data}}">
         <paper-icon-item class="listItems">
          <img class="avatar blue" item-icon src="{{item.image}}">
            <paper-item-body two-line>
                <div class="title">{{item.title}}</div>
                <div secondary>{{item.description}}</div>
            </paper-item-body>
        </paper-icon-item>
        </template>
    </div>
  </template>
    
<script>
    
  Polymer({
    is: "list-binding",,
    ready: function() 
        
      }
  });

There's syntax errors here.

</script>
    
</dom-module>
Reply all
Reply to author
Forward
0 new messages