本文介绍了如何创建一个包含另一个AngularCli的AngularCli应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Angular2中使用AngularCli开发了一个应用程序,我希望将它用作另一个项目的布局(如MasterPage)。就像一个大的SPA系统。

I have an application in development that is in Angular2 using AngularCli, and I want to use it as a "Layout" (like a MasterPage) to another project. Like a big "SPA System".

例如,在菜单中我们将有以下内容:

For example, in the menu we will have the following:


  • 框架


    • Page A


    • Page B

    框架在中运行,XPTO在 http:// localhost:91 。它们都在AngularCli上运行。

    The Framework is running in http://localhost:90 and XPTO is running in http://localhost:91. Both of them is running on AngularCli.

    我想创建一个结构,当我点击页面A或页面B时,浏览器不会重新加载,它会给出用户的app样式,将页面加载为SPA ACROSS站点。

    I want to create a structure that when I click on Page A or Page B, the browser doesn't reload and it will give an "app" style to the user, loading the page as a SPA ACROSS the sites.

    主要原因是重用Javascripts,CSS和de中的许多其他文件其他20个项目的框架项目。我不希望在这些项目中复制所有组件,文件等。

    The main reason is to reuse the Javascripts, CSS and many other files from de "Framework" project to other 20 projects. I don't want to replicate all the components, files and etc across those projects.

    今天我们使用MVC3和RazorGenerator创建.cshtml作为DLL,将Framework中的.cshtml重用到其他模块。

    Today we use MVC3 and the RazorGenerator to create .cshtml as a DLL to reuse the .cshtml from Framework to other modules.

    但我们想要去AngularCli。有没有办法做到这一点?如果不是,有没有办法在AngularCli中创建一个可以重用组件和其他文件的模板?

    But we want go AngularCli. Is there any way to do that ? If it isn't, is there some way to create a template in AngularCli that can be reused the components and the other files ?

    谢谢!

    推荐答案

    您可以将共享的Angular组件和模块放入单独的npm包中,并将此包用作其他项目的依赖项。
    为了引用你的npm包(我假设它不是在npmjs.com上托管),你可以指定一个git存储库或本地路径。
    以下是package.json的示例

    You can put shared Angular components and modules into a separate npm package and use this package as a dependency for other projects.In order to reference your npm package (I assume it's not hosted at npmjs.com) you can specify a git repository or local path.Here is an example of package.json

    {
      "name": "foo",
      "version": "0.0.0",
      "dependencies": {
        "my_git_package": "git+ssh://user@hostname/project.git#commit-ish",
        "my_local_package": "file:../foo/bar"
      }
    }
    

    在这里查看依赖项部分

    这篇关于如何创建一个包含另一个AngularCli的AngularCli应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 18:39