在浏览器和节点环境中都是angular度的

我试图拉一个疯狂的把戏,我有点卡住了。

我需要做的是在AppleTV上使用angular度。 在没有DOM的东西上使用angular的目的是什么? 我试图重用一堆angular度服务,为另一个应用程序编写的,所以我需要使用angular度和它的dependency injection机制的serviceProvider部分。 我可能可以使用node-di进行依赖,可能仍然不能解决serviceProvider部分。

通常我需要做的是加载angular.js代码(也许通过XHR)并评估它。 目前我无法做到这一点,angular对DOM对象有很大的依赖。 我尝试加载angular度,使用jsdom ,它在节点上工作,但没有在AppleTV上。 Jsdom本身也加上了节点。

我能够通过嘲笑所有的DOM依赖来评估它

  Location = -> Location.prototype.href = "" Location.prototype.pathname = "" Window = -> Window.prototype.location = new Location() Window.prototype.addEventListener = -> window = new (Window) global.window = window Element = -> Element.prototype.setAttribute = -> Element.prototype.pathname = "" Element.prototype.addEventListener = -> Element.prototype.find =-> new Element() Document = -> Document.prototype.createElement = -> new Element Document.prototype.addEventListener = -> document = new Document() global.document = document window.document = document Navigator = -> navigator = new Navigator() global.navigator = navigator 
Interesting Posts