2

我正在尝试一个疯狂的把戏,我有点卡住了。

我需要做的是在 AppleTV 上使用 angular。在根本没有 DOM 的东西上使用 Angular 的目的是什么?我正在尝试重用为另一个应用程序编写的一堆角度服务,所以我需要使用serviceProvider角度的一部分及其依赖注入机制。我可能可以使用node-di进行依赖,可能仍然无法解决serviceProvider部分问题。

一般来说,我需要做的是加载 angular.js 代码(可能通过 XHR)并对其进行评估。目前我无法做到这一点,角度对 DOM 对象有大量依赖。我尝试使用jsdom加载角度,它在节点上工作,但在 AppleTV 上没有。Jsdom 本身也与节点耦合。

4

1 回答 1

1

我能够通过模拟所有 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
于 2014-03-05T18:31:08.377 回答