简体   繁体   English

如何呈现从ion-content内的API加载的html

[英]how to render html loaded from API inside ion-content

I'm opening a modal this way: 我正在以这种方式打开模式:

const modal:HTMLIonModalElement =
   await this.modalController.create({
      component: ModalLoteinfoPage,
      componentProps: {
         pageBody:pageBodyLoadedFromAPI
      }
});

Then I'm trying to put the content pageBody as HTML inside ion-content 然后我试图将内容pageBody作为HTML放入ion-content

<ion-content>

  <div [innerHTML]="{{pageBodyLoadedFromAPI}}"></div>

</ion-content>

So I'm getting this error: 所以我得到这个错误:

Error: Uncaught (in promise): Error: Template parse errors:
Parser Error: Got interpolation ({{}}) where expression was expected at column 0 in [{{pageBody}}] in ng:///ModalLoteinfoPageModule

What exactly this error means? 此错误的确切含义是什么? How can I achieve that? 我该如何实现?

If you use binding [] you don't have to use interpolation {{}}, only the variable name. 如果使用绑定[],则不必使用插值{{}},而只需使用变量名。

<div [innerHTML]="pageBodyLoadedFromAPI"></div>

You have to use interpolation if you don't use binding 如果不使用绑定,则必须使用插值

<div innerHTML="{{pageBodyLoadedFromAPI}}"></div>

pageBodyLoadedFromAPI is a angular variable. pageBodyLoadedFromAPI是一个角度变量。 No need for {{}} 无需{{}}

<div [innerHTML]="pageBodyLoadedFromAPI"></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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