第三方网站中的Angular应用程序

时间:2016-07-11 07:21:29

标签: angularjs widget

我正在开发一个可能嵌入第三方网站的角度小部件。由于我不知道我的小部件是否可以嵌入已经加载角度的网站,我必须处理它。

经过一番研究后,我在相同的网页上运行了两个版本的角度。问题来了,因为我的小部件将进行手动引导,而我猜,客户端站点将进行自动引导。这是在显示错误时。

    angular.js:78 Uncaught Error: [$injector:modulerr] Failed to instantiate module appHost due to:
Error: [$injector:nomod] Module 'appHost' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.29/$injector/nomod?p0=appHost
    at https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.29/angular.js:78:12
    at https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.29/angular.js:1679:17

似乎第二个版本的angular尝试从第一个版本(客户端版本)引导一个模块。无论如何它可以工作,但我不能让错误显示在客户端网站上。我不知道是否有更好的方法来封装/隔离我的代码。

我创建了这个example in plunker,以便您可以看到我在说什么。有关如何避免该错误的任何想法?谢谢!

0 个答案:

没有答案