我想在我的 Ionic 2 项目的 LoadingController 的内容选项中使用自定义组件,但是当加载出现时,浏览器控制台向我显示消息:
WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).
并且该组件没有显示,进行测试我意识到使用任何其他不是标准 HTML 标签的标签会引发此错误,我如何使用 Angular 2 安全性来绕过该错误?我想要的是:
this.loadingController.create({
spinner: 'hide',
content: `
<div>
<some-component></some-component>
<h3>a message...</h3>
</div>`
})
最佳答案
实际上,根据the doc:,你不能那样做
content ----> string ----> The HTML content for the loading indicator.
所以你必须像这样传递纯 string
HTML 内容:
content: `
<div class="my-spinner">
<div class="my-spinner-box"></div>
</div>`,
关于angular - Ionic 2 LoadingController 包含自定义内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43020949/