I am planning to develop my company's CRM (Customer Relationship Management) system in AngularJS. This system is not small, there are modules like customer CRUD, Shopping Cart, After-Sales Service, and so on.
我计划在AngularJS中开发我公司的CRM(客户关系管理)系统。这个系统不小,有客户CRUD,购物车,售后服务等模块。
As I noticed, usually an AngularJS has just one main "ng-app".
正如我所注意到的,通常AngularJS只有一个主要的“ng-app”。
-
Is there any problem to build more than on "ng-app" for a system (one for each CRM module)?
对于系统(每个CRM模块一个),构建多于“ng-app”的问题是否有任何问题?
-
What would be its pros and cons?
它的优点和缺点是什么?
Edit 1: I am not planning to use more than one ng-app per HTML, but many (about 7) in the whole application.
编辑1:我不打算每个HTML使用多个ng-app,但整个应用程序中有很多(约7个)。
Edit 2: The idea is create one Angular Module for each CRM module, for example:
编辑2:想法是为每个CRM模块创建一个Angular模块,例如:
customer.html<html lang="en" ng-app="crmCustomer">
angular.module('crmCustomer', ['customers']);
customer.html angular.module('crmCustomer',['customers']);
sales.html<html lang="en" ng-app="crmSales">
angular.module('crmSales', ['customers','cart','sales']);
sales.html angular.module('crmSales',['customers','cart','sales']);
afterSales.htmlangular.module('crmAfterSales', ['customers', 'remittance']);
<html lang="en" ng-app="crmAfterSales">
afterSales.html angular.module('crmAfterSales',['customers','remittance']);
1 个解决方案
#1
I've found using multiple apps in one page is burdensome (as you can see in solutions linked by Amruth Rao) and rather creates issues than solves any.
我发现在一个页面中使用多个应用程序很麻烦(正如您在Amruth Rao链接的解决方案中看到的那样)而不是解决任何问题。
Instead, I create a 'root' app and add the modules I need, ex.:
相反,我创建了一个“根”应用程序并添加了我需要的模块,例如:
angular.module('crm', ['customers', 'cart', 'sales']);
Just make sure the components in those modules have different names, maybe by prefixs.
只需确保这些模块中的组件具有不同的名称,可以通过前缀。
#1
I've found using multiple apps in one page is burdensome (as you can see in solutions linked by Amruth Rao) and rather creates issues than solves any.
我发现在一个页面中使用多个应用程序很麻烦(正如您在Amruth Rao链接的解决方案中看到的那样)而不是解决任何问题。
Instead, I create a 'root' app and add the modules I need, ex.:
相反,我创建了一个“根”应用程序并添加了我需要的模块,例如:
angular.module('crm', ['customers', 'cart', 'sales']);
Just make sure the components in those modules have different names, maybe by prefixs.
只需确保这些模块中的组件具有不同的名称,可以通过前缀。