javascript - How to use the same code base to create another project with some shared services and components?
问题描述
We already have a web application which is suitable and designed for desktop users, now we decided to use Angular power and develop a new version of our website just for mobile device users.
I mean we want to have another version on our website which is fully optimized for our mobile users and this method is named adaptive design.
We detect user type by getting the User-Agent and serve the different web app based on the device type.
We want to use our services, models, directive and pipes, but only components and view, and some logic changes. How can we have multiple Angular projects which use one source base or application? There are lots of shared code which does not need to be re-written
解决方案
您可以为所有组件、服务、模型、指令和管道使用两个项目以及一个共享库。开箱即用的 Angular CLI 支持该配置。
如何设置多个项目:
https://angular.io/guide/file-structure#setting-up-for-a-multi-project-workspace
如何创建和使用库
推荐阅读
- swiftui - SwiftUI:如何初始化依赖于视图中另一个变量的变量
- linux - Docker 卷绑定时,Chown 权限被拒绝
- c# - ASP.NET MVC 模型数据未更新
- python-3.x - 删除字符串中两个特定单词之间的字母
- scala-breeze - 矩阵乘法:错误:方法 *:* 的参数太多
- kubernetes - 如何将文件/应用程序添加到持久卷以供我的 pod 读取
- java - 集群中 ServletContextListener 的单个实例
- android - 打开两个不同风格但代码库相同的实例
- c# - Npgsql 包给出 System.TypeInitializationException
- python - 为什么安装 `pypiwin32` 或 `pywin32` 在作为依赖项安装时会失败,但在单独使用 pip 时会成功?