AngularJS模块命名空间的常见方法是什么?

4

我刚接触AngularJS,正在想象在应用程序中如何命名空间模块。

有一个限制条件:我需要将我的Angular应用程序嵌入到第三方网站的占位符div中(可能也使用了Angular),而不能使用iframe。因此,我不能简单地创建没有命名空间的模块,比如angular.module('users'),因为它可能会和第三方应用程序中已经定义的任何 'users' 模块冲突。

我想到了以下组织方式:

angular.module('mycompany.productname', [
    'ngRoute',
    'mycompany.productname.forms',
    'mycompany.productname.users',
    'mycompany.productname.services'
]);

angular.module('mycompany.productname.forms').controller('formEditController', ['$scope', function($scope) { ...

angular.module('mycompany.productname.users').controller('userAccountController', ['$scope', function($scope) { ...

angular.module('mycompany.productname.users').controller('userLoginController', ['$scope', function($scope) { ...

angular.module('mycompany.productname.services').service('forms', ['$scope', function($scope) { ...

根据我的限制条件,是否有更常见的解决方案?

1
看起来很不错。我喜欢给事物取非常相似的名称 :) - Matt Way
为什么我们要投票关闭这个问题?难道它对你们来说不够客观吗?看着这个问题在接下来的4个月内获得1,000次浏览。 - Chad Johnson
1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接