[英]How to Integrate angular 4 or higher with express
i want to integrate angular 4 or higher than that with my existing express folder.我想将 angular 4 或更高版本与我现有的 express 文件夹集成。
As i am new to mean stack development i want clean and understandable steps how to integrate angular with express.因为我是堆栈开发的新手,所以我想要清晰易懂的步骤,如何将 angular 与 express 集成。
Anyone having reference links for the following::任何有以下参考链接的人:
Integrating Angular and Express can be done through a single server.js
file placed in the root directory of your Angular project.可以通过放置在 Angular 项目根目录中的单个
server.js
文件来集成 Angular 和 Express。 Use Angular CLI to ng build --prod
and generate a dist/
folder.使用 Angular CLI
ng build --prod
并生成一个dist/
文件夹。 You can then link the dist/
folder through the following code in your server.js
file and running node server.js
.然后,您可以通过
server.js
文件中的以下代码链接dist/
文件夹并运行node server.js
。
// Define variables const express = require('express'); const app = express(); // Use the /dist directory app.use(express.static(__dirname + '/dist')); // Catch all other invalid routes app.all('*', function(req,res){ res.status(200).sendFile(__dirname + '/dist/index.html'); }); // Start the server app.listen(process.env.PORT || 3000);
The Mongoose Docs are very good, but if you need a video, this one: Mean Stack Front to Back: Part 3 is a nice code-along you can work with. Mongoose Docs非常好,但是如果您需要视频,这个视频: Mean Stack Front to Back:第 3 部分是一个很好的代码,您可以使用它。 The Mongoose part starts about 90 seconds into the video.
Mongoose 部分从视频开始约 90 秒开始。
This website gives a nice CRUD Example and also goes into Mongoose as well.该网站提供了一个不错的CRUD 示例,并且也介绍了 Mongoose。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.