首页 > 解决方案 > 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

标签: javascriptangular

解决方案


您可以为所有组件、服务、模型、指令和管道使用两个项目以及一个共享库。开箱即用的 Angular CLI 支持该配置。

如何设置多个项目:

https://angular.io/guide/file-structure#setting-up-for-a-multi-project-workspace

如何创建和使用库

https://angular.io/guide/creating-libraries#getting-started


推荐阅读