angular - Ionic 2 LoadingController 包含自定义内容

标签 angular typescript ionic2

我想在我的 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/

相关文章:

javascript - Typescript/Lodash group by——尝试将数组键的值与其数量分组

node.js - 语法错误 : Cannot find name 'setImmediate'

javascript - 带参数的自定义验证

angular - 我如何跟踪 ionic 2 中 app.component.ts 中的每个错误

angular - 具有 Angular 2 重新加载问题的 Electron App

html - 如何更改 Angular-6-datatable 中分页器的背景颜色

angular - Angular 模板中 getter 的性能影响

angular - Ionic 2 管道 - Uncaught Error : No Directive annotation found on MapToIterable(…)

javascript - 从 DOM 元素获取文本并将其插入到 'title' typescript

javascript - 如何使用 nav.popTo() (ionic 2)?