Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

Ranch Hand
Posts: 165
Tomcat Server Java 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
Posts: 67401
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
What's that smell? Hey, sniff this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic