我有一个GP练习地址的开头,其开头如下(不是超过16000个条目的整个Feed - 仍然需要弄清楚分页)
[{"Address1":"73 UPPER WICKHAM LANE","Address2":"WELLING","Address3":"KENT","Address4":"","Address5":"","CloseDate":"\/Date(-62135596800000+0000)\/","ContactName":"","ContactTelephone":"020 88541910","EmailAddress":"","LastUpdatedDate":"\/Date(1434749040000+0100)\/","Name":"(GPSI) DR AC BARUAH","OpenDate":"\/Date(-62135596800000+0000)\/","OrgSubTypeCode":"B","PCTCode":"TAK","Postcode":"DA16 3AF","PracticeCode":"Y00789","PracticeType":"0","SendToEDTHub":false,"SendToEmail":false,"SendToPrinter":true,"Status":"C"},
{"Address1":"73 UPPER WICKHAM LANE","Address2":"","Address3":"WELLING","Address4":"KENT","Address5":"","CloseDate":"\/Date(-62135596800000+0000)\/","ContactName":"","ContactTelephone":"020 88541910","EmailAddress":"","LastUpdatedDate":"\/Date(1434749040000+0100)\/","Name":"(GPSI) DR AP DHITAL","OpenDate":"\/Date(-62135596800000+0000)\/","OrgSubTypeCode":"B","PCTCode":"TAK","Postcode":"DA16 3AF","PracticeCode":"Y00788","PracticeType":"0","SendToEDTHub":false,"SendToEmail":false,"SendToPrinter":true,"Status":"C"},
{"Address1":"2 CHURCH AVENUE","Address2":"","Address3":"SIDCUP","Address4":"KENT","Address5":"","CloseDate":"\/Date(-62135596800000+0000)\/","ContactName":"","ContactTelephone":"020 83021114","EmailAddress":"","LastUpdatedDate":"\/Date(1434749040000+0100)\/","Name":"(GPSI) DR HL BHATTAD","OpenDate":"\/Date(-62135596800000+0000)\/","OrgSubTypeCode":"B","PCTCode":"TAK","Postcode":"DA14 6BU","PracticeCode":"Y00791","PracticeType":"0","SendToEDTHub":false,"SendToEmail":false,"SendToPrinter":true,"Status":"C"}
.
.
.
将mime-type application / json返回给调用应用程序
以下代码是HTML代码段,我认为它会调用以获取数据并显示它。
<paper-material elevation="1">
<div id="GPPracticeContainer">
GP List
{{data}}
<template is="dom-repeat" items="{{data}}"
<p>{{item.Name}}</p>
</template>
</div>
</paper-material>
</paper-header-panel>
<iron-ajax auto id="GPCollection"
url="/GPPractices.ashx"
handle-as="json"
last-response="{{data}}"
on-response="handleGPCollection">
</iron-ajax>
最后是javascript
<script>
function handleKeyPress(e) {
if (e.keyCode == 13) {
alert('off to search for something!');
}
};
Polymer({
is: "practice-list",
hideSearch: {
type: Boolean,
value: false
},
handleGPCollection: function(request) {
alert('GP Practices collected ' + request);
},
ready: function () {
this.hideSearch = true;
this.$.searchText.keyup(function (e) {
alert('off to search for something!');
});
},
srchandler: function () {
// search for contents of search box is showing, otherwise show it.
if (!this.hideSearch)
{
alert('off to search for something!');
}
else {
this.hideSearch = !this.hideSearch;
if (!this.hideSearch) {
this.$.searchText.focus();
}
}
}
});
</script>
虽然出现警告框显示数据已被读取 - 但返回Object CustomEvent但是没有数据出现。
任何人都知道我怎么能
a)找出问题所在 b)让它显示说出每个练习的名称
由于
答案 0 :(得分:0)
我错过了结束&#39;&gt;&#39;的模板。它应该读
<template is="dom-repeat" items="{{data}}">
<p><span>{{item.PracticeCode}}</span> - <span>{{item.Name}}</span></p>
</template>