Я пишу простой элемент, загружающий html-файлы с помощью вспомогательной функции Polymer 1.0 importHref()
. Страница загружается, но вместо HTML-рендеринга на страницу я получаю [object HTMLDocument]
.
Когда я регистрирую успешный обратный вызов, импортированная страница оборачивается в объект #document
(не уверен в терминологии здесь). Но вся информация есть в консоли.
Итак, мой вопрос: как мне отобразить html на странице?
элемент:
<dom-module id="content-loader">
<template>
<span>{{fileContent}}</span>
</template>
<script>
Polymer({
is: "content-loader",
properties: {
filePath: {
type: String
}
},
ready: function() {
this.loadFile();
},
loadFile: function() {
var baseUrl;
if (!window.location.origin)
{
baseUrl = window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}
else
{
baseUrl = window.location.origin;
}
//import html document and assign to fileContent
if(this.filePath)
{
this.importHref(baseUrl + this.filePath, function(file){
this.fileContent = file.target.import;
console.log(this.fileContent); //logs fine
},
function(error){
console.log(error);
});
}
}
});
</script>
in use:
<content-loader file-path="/app/general/contact.html"></content-loader>