Thanks a lot @zewa666, my dumbself is not able to get the bindings processed.
Here is the snippet.
welcome.ts
async attached(){
const response = await this.http.fetch('/');
this.templateBlob = await response.text();//bound to innerHtml
const templatePanelArr = document.getElementById("templatePanelId");
this.data = {
lessor: {
firstName:'FN lessor',
lastName: 'LN lesser'
},
lessee: {
firstName: 'LL FN',
lastName: 'LN LL'
},
address: 'NDLS',
startDate: '12/12/2019',
endDate: '20/03/2020'
};
const eins = <EnhanceInstruction>{
element: templatePanelArr,
container: this.container,
bindingContext: {
message: 'This is some instruction',
heading: this.heading,
...this.data
}
};
this.getTemplatingEngine().enhance(eins);
/* const factory = this.viewCompiler.compile(templatePanelArr);
factory.create(this.container, { enhance: true });*/
}
welcome.html
<div innerHtml.bind="templateBlob" id="templatePanelId">
</div>
HTML returned by REST API.
<section>
${heading}
<p>
${message}
</p>
<p>
This is a agreement between ${lessor.firstName} ${lessor.lastName} and ${lessee.firstName} ${lessee.lastName}.
</p>
<p>
Signed at property address ${address}.
</p>
<p>
Valid between dates ${startDate} and ${endDate}.
</p>
</section>
The bindings are not processed and values does not appear.
If i call the enhance
on button click in the same view, something undefined
is being returned.
/** Called on click of a button in welcome.html/ts. **/
doStuff() {
const templatePanelArr = document.getElementById("templatePanelId");
console.log('Doing stuff.....', templatePanelArr);
const eins = <EnhanceInstruction>{
element: templatePanelArr,
container: this.container,
bindingContext: {
message: 'This is some instruction',
heading: this.heading,
...this.data
}
};
this.templateEngine.enhance(eins);
console.log('Doing stuff 2.....', templatePanelArr);
}
The console output:
<div innerhtml.bind="templateBlob" id="templatePanelId" class="au-target au-target au-target" au-target-id="21">undefined</div>
please help. Thanks a lot for your time.