angular和地图插件的问题

http://segmentfault.com/q/1010000002484757

这个问题感觉并没有说的太清楚。

引用高德地图的SDK就会有警告。
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.

像这种需要加载js,或者操作dom的插件,改怎么和angularjs一起用呢?

阅读 5.2k
2 个回答

异步JS加载和执行document.write时document已经close,这是错误的原因;document.open会重置整个document;应该修改代码用非document.write的DOM操作,比如.innerHTML和appendChild。

想要和angularjs搭配使用,需要自己封装成directive或者provide,可以看 angular-ui-googlemap 的封装

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题