简体   繁体   中英

Iron-list doesn't show AJAX results

I've got an iron-list inside a paper-dialog I would like to fill with data from an AJAX-request. The response from the server looks like this:

[{"name":"Bob"},{"name":"Tim"},{"name":"Mike"}]

This is my custom Polymer component:

<link rel="import" href="../../bower_components/iron-list/iron-list.html">
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">

<dom-module id="my-dialog">
  <template>
    <iron-ajax id="getAjax" url="/getdata" handle-as="json" lastResponse="{{data}}" auto></iron-ajax>
    <paper-dialog id="loadDialog">
      <h2>Header</h2>
        <iron-list items="[[data]]" as="item" style="height:200px">
          <template>
            <div>
              Name: <span>[[item.name]]</span>
            </div>
          </template>
        </iron-list>
    </paper-dialog>
  </template>

Why is the list staying empty?

lastResponse必须重命名为last-response

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM