Gavra
Gavra

Reputation: 51

JHipster nested component

I have defined two entities:

entity Company {
  name String required 
}

entity CompanyAddress {
  street String,
  number String
}

relationship ManyToOne {
  CompanyAddress{company(name)} to Company
}

After running jhipster import-jdl two new entities are created company and company-address

What i want to do is to display list of addresses of a company in company-detail.component

When i place in company-detail.component intellij idea instructs me to import company-address module.

When i do that, application routing doesn't work correctly any more, because i am not able to go to company component from main menu, instead i am routed to company-address.component.

So, what is the correct way to achive this?

Thanks

Upvotes: 1

Views: 616

Answers (1)

Jochen Haßfurter
Jochen Haßfurter

Reputation: 915

An Angular application can have one Router-Object. You create a router module and a service in the app root module. The SPA can have one or more router-outlets, where linked components will be rendered. These components can be loaded with the root app or lazily to keep the initial size minimized. Lazy-loaded components can be preloaded. And the Router can be passed with or without data to its child.

The child component can add its routes-configuration to the Object. The Router is also dispatching events, which can be intercepted. And the routes can be guarded (e.g. "only allow logged in users to render the linked component").

JHipster generates a best practice "template" Angular frontend (if chosen), which is of course complete and ready out of the box to fully use the generated Spring backend. With all features like centralized configuration, authentication and protection measures all over the application, translation, the possibility to fill, update and read your databases with the frontend and/or an API, dev- and prod-configuration and a lot more you have to think of to build a scalable, extendable, business-proof up-to-date application, monolithic or in a microservice architecture.

Additional tasks, another opinion in user guidance and operability etc. of your application may have to be implemented on your own. JHipster shows you how to do that in an opinionated way and will lead to good code. With JHipster you get the knowledge from a lot of experienced full-stack developers in your hands - for free! It's miraculous what they're doing!

Try to build side-by-side to be able to use generator-jhipster not only as initial generator but also to stay up to date with your app with the help of the JHipster upgrade feature. Code often has its decay period, opinions do change - Hipster stay up to date.

Or use JHipster to test your ideas fast and comprehensive.

Or use it to learn what have to be thought of to build professional applications.

Upvotes: 1

Related Questions