我有一个GP Practice的提要,其开头如下(不是整个提要超过16000项的提要-仍然需要弄清楚分页)
[{"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类型的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)让它显示每个练习的名称
谢谢
我缺少模板的结尾'>'。它应该读
<template is="dom-repeat" items="{{data}}">
<p><span>{{item.PracticeCode}}</span> - <span>{{item.Name}}</span></p>
</template>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句