[英]Angular modules for admin/user scenario
I'm designing an Angular application which has admin and basic user view of every major feature.我正在设计一个 Angular 应用程序,它具有每个主要功能的管理员和基本用户视图。
Let's say I have two features - Users and Products , where each User
can have none or many Products
.假设我有两个功能——用户和产品,每个
User
可以没有或有很多Products
。
Each User
can create, view and manage their own profile and connected Products
.每个
User
都可以创建、查看和管理自己的个人资料和连接的Products
。 Admin can create, view and manage all Users
and all Products
, as well as Products
for each User
.管理员可以创建、查看和管理所有
Users
和所有Products
,以及每个User
的Products
。
I'd like to avoid loading admin-specific stuff for basic users and vice-versa.我想避免为基本用户加载特定于管理员的内容,反之亦然。 I guess lazy-loading is the key.
我想延迟加载是关键。 My question is do I create one module for each feature and divide basic , admin and shared stuff inside, or should I make basic , admin and shared my main modules, and divide from there?
我的问题是我是否为每个功能创建一个模块并在里面划分基本、管理和共享的东西,或者我应该制作基本、管理和共享我的主要模块,然后从那里划分?
Or is there a better approach I'm not thinking of?或者有没有更好的方法我没有想到?
You can use angular guards to restrict normal user to access your Admin module.您可以使用 angular 守卫来限制普通用户访问您的管理模块。 In my opinion you should have separate modules for Admin, User, Products and Shared to share common resources across.
在我看来,您应该为管理员、用户、产品和共享设置单独的模块,以共享公共资源。 In this way you can keep the modules separated and even implement lazy loading specific to each module as well.
通过这种方式,您可以保持模块分离,甚至还可以实现特定于每个模块的延迟加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.