I created an angular 2 module and routed it successfully to "dashboard." I'd like to replace the default jHipster homepage with my module, but I can't seem to make it work. Is there something special about the home route or home component or route that I need to know about to swap them for a different module?
Parenthetically, I would like to use jHipster as he basis for my angular2/webpack/spring-boot app, but I am having trouble finding documentation on all the bells and whistles. A recommendation for a thorough reference (if there is one, wold be appreciated)
TIA!
It depends on how you want to do it, JHipster generates code and then it's up to you to modify it.
src/main/webapp/app/home
which defines *HomeModule
. Then yo jhipster:upgrade
command will do its best to keep your modifications using git merge when updating JHipster code to newer version.*HomeModule
unchanged, add a new one using same component selector and replace its reference to *HomeModule
in src/main/webapp/app/app.module.ts
to your new module.Is this what you're asking for? How does one modify the JHipster home page?
This wasn't "swapped out". I started modifying the JHipster app after generation. Gael has provided good answers but I think you're expecting an Angular lesson. The great feature that JHipster provides is a template for your application. It's up to you to modify it.
To redirect after login you should change login() in login.component.ts file. Add
this.router.navigate(['dashboard']);
login () {
this.loginService.login({
username: this.username,
password: this.password,
rememberMe: this.rememberMe
}).then(() => {
this.authenticationError = false;
this.activeModal.dismiss('login success');
if (this.router.url === '/register' || this.router.url === '/activate' ||
this.router.url === '/finishReset' || this.router.url === '/requestReset') {
this.router.navigate(['']);
}
this.eventManager.broadcast({
name: 'authenticationSuccess',
content: 'Sending Authentication Success'
});
// // previousState was set in the authExpiredInterceptor before being redirected to login modal.
// // since login is succesful, go to stored previousState and clear previousState
let previousState = this.stateStorageService.getPreviousState();
if (previousState) {
this.stateStorageService.resetPreviousState();
this.router.navigate([previousState.name], { queryParams: previousState.params });
}
this.router.navigate(['dashboard']); // <-Add here
}).catch(() => {
this.authenticationError = true;
});
}
I also have question, did you manage to put two entities component on dashboard?
1st Identify the route path by searching for
path: ''
You will find it in the app/home/home.route.ts
add some characters of your choice to the empty string to put the Jhipster home component on a different URI path.
since it is set to an empty string it is what is displayed by default if no URI is specified.
2nd if you want to set a different component to the default you will need to create a new module ("dashboard.module"), component ("dashboard.component") and route ("dashboard.route") you can use the home component as a code reference.
In the new landing pages route (dashboard.route.ts) set an empty string as the path
path: ''
3rd register the module in the app.module and viola.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.