简体   繁体   中英

Angular2 app on a different HTML page

I'm working on an Angular2 app and have a requirement to not bootstrap the application on index.html. Given that NG2 uses the HTML5 routing features, this doesn't work too well if you are not using index.html as your bootstrap. (Especially if you refresh the page)

  1. What is the preferred way to bootstrap an NG2 application, not on index.html?

  2. How do you preserve the url/routing so that a page refresh works? (again, not on index.html)

you can totally serve Angular on any HTML page, Route persistence depends on your server technology.

If you are using angular-cli, you can configure index file in .angular-cli.json file

"index": "myhomepage.html"

Whenever a route is called it goes to server to look up the Files, If your Server is configured to correctly Route they can be persisted.

Hope this helps!!

您可以在应用程序根模块中使用APP_BASE_HREF

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM