0

How do you access an angular factory object without using DI that angular provides? For example, I want to have a separate script that adds some server properties to a factory object outside of angular (in a .cshtml file). I don't want to assign the factory object to a separate variable as that would create a global variable.

4

1 回答 1

0

我不确定我是否 100% 了解您想要实现的目标,但如果我没记错的话,您想在角度上下文“外部”获取工厂对象。

var factoryObject = angular.injector(['nameOfYourModule']).get('factoryname');
于 2014-03-07T20:10:47.587 回答