如何将Angular2用作非SPA? [英] How to use Angular2 as a non-SPA?

查看:56
本文介绍了如何将Angular2用作非SPA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用Angular2,发现在网上可以找到的所有教程仅说明了如何为单页应用程序(SPA)设置Angular2.

I have just started out with Angular2 and found out that all tutorials that can be found on the web only explains how to setup Angular2 for Single Page Apps (SPA).

但是,对于我网站的主页,我仍然想使用PHP,而只是在诸如Login/Signup/Contact之类的一些地方使用Angular2.

However for the homepage of my site I still want to use PHP and just use Angular2 on a few places like Login/Signup/Contact, etc.

如何在联系人页面上初始化联系人组件,在登录页面上初始化登录组件,等等?

How is that possible to initialize the Contact Component on the contact page, Login Component on the login page, etc?

我不希望它们一次全部加载,只是一个简单的组件即可处理登录,注册等功能.

I don't want all of them to load at once, just a simple component that handles the logging in, signing up, etc functions.

我相信在Bootstrapping部分需要做些什么,但是究竟是什么?

I beleive something need to be done on the Bootstrapping part, but what exactly?

编辑:我也可能要在一页上使用登录+注册"组件.

I also might want to use the Login + Signup componenents on one page.

推荐答案

我认为您可以引导该页面上所需的任何组件

I think you could bootstrap whatever component you need on that page

import {bootstrap}    from '@angular/platform-browser-dynamic';
import {ContactComponent} from './contact.component';

bootstrap(ContactComponent);

这篇关于如何将Angular2用作非SPA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆