我刚接触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) { ...
根据我的限制条件,是否有更常见的解决方案?