angular4-router

Spring Boot/Angular 4 - Routing in app hits the server

荒凉一梦 提交于 2019-12-03 16:23:09
问题 I have an Angular 4 (ES6) app that I want to serve from a Spring Boot application. My Angular app has an index.html, and when the address of http://localhost:8080 is hit, Spring Boot knows to map to the index.html file which in Angular is mapped to "/search". However, I have another route called "adminlogin" which I would access through http://localhost:8080/adminLogin But in this instance, it hits my Spring Boot application, which doesn't have a mapping and then it throws an error. How do I

Read route params from directly entered url in app

拜拜、爱过 提交于 2019-12-02 08:12:36
My question would be regarding angular 4, how to get route params, if for example a user gets on your page with, instead of the default url, like for example http://localhost:3000/ , to something like http://localhost:3000/user/:id , and to be able to pick up the :id from that url (user has directly entered it in the browser, not navigating through the app). In the example bellow same component is used, mainly because of needing to catch that id and dispatch other actions, if its present, and that would be it. I have tried playing around with ActivatedRoute but from what I could tell so far,

Angular - Add target to router navigate

会有一股神秘感。 提交于 2019-12-02 02:12:49
问题 What I want to do is to open the target of router navigate in another tab or in a popup. My instruction is this: private router: Router; this.router.navigate(['/page', id]); In routing I have: const routes: Routes = [ { path: '', component: LayoutComponent, children: [ { path: 'page', loadChildren: './page/page.module#PageModule' } ] } ]; I would like to open this link in another tab or in popup window. What can I do? this is the code of page.ts @Component({ selector: 'app-etichetta',

Angular 4 remove hash(#) from url

孤者浪人 提交于 2019-12-01 01:27:43
my app.module.ts @NgModule({ ....... providers: [ .... { provide: LocationStrategy, useClass: HashLocationStrategy}, .... ] }); when i remove this part, it's works in my localhost but after taking a ng build or ng build --prod , when i refresh the page or h5 it doesn't work. It gives 404 error. I want to remove hash(#) from my url . Any solution ? You can check the angular guide about deployment Let's talk about the difference between HashLocationStrategy and PathLocationStrategy . For more info, check the docs Angular, by default, uses PathLocationStrategy . Let's say you have following

Angular 4 remove hash(#) from url

牧云@^-^@ 提交于 2019-11-30 20:37:52
问题 my app.module.ts @NgModule({ ....... providers: [ .... { provide: LocationStrategy, useClass: HashLocationStrategy}, .... ] }); when i remove this part, it's works in my localhost but after taking a ng build or ng build --prod , when i refresh the page or h5 it doesn't work. It gives 404 error. I want to remove hash(#) from my url . Any solution ? 回答1: You can check the angular guide about deployment Let's talk about the difference between HashLocationStrategy and PathLocationStrategy . For