如何创建angularjs私人工厂吗? [英] How to create private factory in angularjs?

查看:130
本文介绍了如何创建angularjs私人工厂吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用工厂的myapp,是有可能创造的角度JS的私人工厂。

I am using factory for myapp , is it possible to create a private factory in angular js.

module.factory('ParentService', function ($q, $http) {
  return {
//public API
 };
});



module.factory('ChildService', function (ParentService, $sce) {
   var child = Object.create(ParentService);
   child.childMethod = function () {
//extending the parent
};
return child;
});

我希望我的ParentService是私有的,这样其他控制器拥有访问它。

I want my ParentService to be private so that no other controller have the access to it.

推荐答案

您不能在AngularJS 1.x中创建它们在未来有可能是模块范围的服务/工厂,但没有人来实现他们没有。

You can't create them in AngularJS 1.x. In future there may be module-scoped services/factories but nobody has implemented them yet.

这篇关于如何创建angularjs私人工厂吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆