简体   繁体   English

如何将我的节点项目与 angular 合并?

[英]How do i merge my node project with angular?

I have made a project in nodeJs which updates data of my database and I've made a separate project in angular for designing front end of the form.我在 nodeJs 中创建了一个项目来更新我的数据库的数据,并且我已经在 angular 中创建了一个单独的项目来设计表单的前端。

How do I merge these two different projects so that form data passed in angular project is handled by nodejs project?如何合并这两个不同的项目,以便在 angular 项目中传递的表单数据由 nodejs 项目处理? so basically I want to make a full app having both front and well as back end.所以基本上我想制作一个具有前端和后端的完整应用程序。 Thanks.谢谢。

If you've developped your Rest Api in NodeJs with all the urls, you can call them in Angular by following the steps:如果您已经使用所有 url 在 NodeJs 中开发了您的 Rest Api,您可以按照以下步骤在 Angular 中调用它们:

1- In Angular, create a service ( ng generate service dummyService) 1- 在 Angular 中,创建一个服务(ng generate service dummyService)

2- Create the functions to interact with you NodeJs server: 2- 创建与您的 NodeJs 服务器交互的函数:

dummyFunction() {

   return this.http.get(backendUrl).pipe(map(res => res))
}

3- Call the Service in your components and retrieve/Send Data as you wish 3- 在您的组件中调用服务并根据需要检索/发送数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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