This week's book giveaways are in the Functional Programming and Linux forums.
We're giving away four copies each of Reactive Design Patterns and Learn Linux in a Month of Lunches and have the authors on-line!
See this thread and this one for details.
Win a copy of Reactive Design Patterns this week in the Functional Programming forum
or Learn Linux in a Month of Lunches in the Linux forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to integrate service layer with database in Angular 2 web app and do packaging for deployment?

 
Vinod Vijay
Ranch Hand
Posts: 162
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new Angular2 and learning it using TypeScript. I understood that everything is component in Angular2 and we do not render whole HTML page but by just specific component. I have 2 basic queries here:-

1) In my sample, Angular 2 app, I have service component class which brings static data to my component class using Dependency Injection. Instead of static, I want to bring data from my database (MongoDB). Between service layer and database, I'm quite confused. May I know what are industry best approaches to integrate service layer and database layer in a regular Angular 2 app? Do we have tightly coupled architecture like normal JAVA J2EE MVC architecture from controller to service to dao to hibernate/JDBC/ibatis or do we integrate using web services (RESTful APIs'), loose-coupled fashion?

2) Secondly, how do we package this Angular 2 web app? Do we simply zip it or export as WAR file? Currently, I'm running it on my local system using my Node.js (npm start, etc on command prompt) and using Visual Studio Code for coding? How to create WAR file and does Tomcat App server supports Angular 2 apps?

Thank you
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65419
100
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) After moving of from Angular 1, I've been looking into React/Redux, and so am unfamiliar with Angular 2 at this point. (That will likely change in the future, but of now...) That said, most component architectures (including React/Redux) do not recommend mixing presentation components (those that represent visual elements) with backend data details. In React/Redux, one currently popular approach is to create non-presentational "container" components that take care of data details as managed by the Redux store.

I would suggest searching for articles on the same subject for Angular 2 to see what patterns and approaches are being widely used in that arena.

2) Why would you need to serve a client-only web application from a JEE server? As there is no backend, you can serve it from any simple web server.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!