将Angular2应用程序集成到现有站点中

时间:2016-08-02 12:49:00

标签: angular

我使用Angular Cli在Angular2(RC4)中构建了一个测试应用程序 该应用程序非常简单,有3个组件和3个路由 我使用Angular Cli在prod中构建应用程序 现在我想将这个应用程序集成到现有站点(例如在页面上),其方式不会影响我站点的路由器。 我的想法是让这个Angular2应用程序像我的网站上的功能/插件。

我希望实现的效果更类似于用Fiddler,Plunker等编写的Angular2应用程序(您可以在结果窗口中看到应用程序并更改状态不会更改浏览器选项卡的URL)。 example

我绝对不想使用<iframe>

我在谷歌寻找一些信息,但我找不到任何东西 我找到的最近的建议是:

... <!--Existing site -->    
<section class="here"></section>
<script>$('.here').load('angular2App/index.html'); //the index.html of build anguar2 app</script>

这不起作用,需要对所有hrefsrc等进行大量修改

我的路由器(app.routes.ts)如下所示:

import { provideRouter, RouterConfig } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';

const routes: RouterConfig = [
    {
        path: '',
        component: HomeComponent
    },
    {
        path: 'about',
        component: AboutComponent,
    }
];

export const APP_ROUTER_PROVIDERS = [
    provideRouter(routes)
];

如何将Angular2应用程序集成到现有网站?

0 个答案:

没有答案