【发布时间】:2015-02-27 15:51:24
【问题描述】:
我目前正在为自己的一个新博客使用 angular 和 rails,但我被困住了。我使用ng-bind-html 从后端注入代码。
现在我使用自己的指令修复了它。
当我尝试从 Github 的 Gist 服务导入代码示例时,我目前收到以下错误:
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
这是什么原因以及如何解决这个问题?提前致谢!
【问题讨论】:
-
看起来很明显,你不能在页面加载后使用
document.write,否则它会清除页面中的所有内容 -
需要更多信息/代码示例/用于帮助您的库。我遇到了类似的问题。我使用了gist-embed 库。使用 ng-bind-html 时,我必须使用
gist()重新编译绑定的 html。也看看github.com/pasupulaphani/angular-gist-embed,它可能对你有帮助。
标签: javascript ruby-on-rails angularjs asynchronous