angular-routing

Angular how to get the non activated children routes

旧城冷巷雨未停 提交于 2021-02-19 03:38:06
问题 In Angular you can always inject ActivatedRoute in your component to get a reference to the current activated route. It has a property children which: Contains all the child routes activated under the current route. I was wondering how can I get all the children routes (so also the non activated ones). 回答1: You could use route.routeConfig.children to get the children defined in the router. 来源: https://stackoverflow.com/questions/46069944/angular-how-to-get-the-non-activated-children-routes

How to use PathLocationStrategy on localhost?

六月ゝ 毕业季﹏ 提交于 2021-02-11 13:21:14
问题 I'm working on an Angular 4 web app and I need to use PathLocationStrategy (not HashLocationStrategy ). The only problem with PathLocationStrategy is that when I refresh a page, I instantly get a blank page with 404 errors in the console... Which is normal with PathLocationStrategy . Once on a server, I can fix that by redirecting the routes to point on index.html. But how to fix this issue on localhost when I launch my app with ng serve ? It would be ideal since I'm working in "livereload",

How to run ng serve with PathLocationStrategy while falling back to index.html when page is refreshed

情到浓时终转凉″ 提交于 2021-02-11 06:48:15
问题 For some reasons (e.g Hiding the # from the user), we would like to use PathLocationStrategy as the routing strategy for our Angular 8 Application. We are about to fallback to index.html while deploying the application to an Nginx server. But the problem we are facing is, when we run ng serve locally, the application won't bootstrap when page is refreshed. I have tried to use a custom webpack config to enable devServer.historyApiFallback, it doesn't work. I have also read through quite a few

Angular routing keep child parameters

空扰寡人 提交于 2021-02-10 16:16:01
问题 I have the following route configuration: const routes: Routes = [ { path: '', component: HomeComponent, canActivate: [AuthGuard], children: [ { component: DashboardComponent, path: '' }, { component: UnitComponent, path: 'unit/:serialnumber', children: [ { path: '', redirectTo: 'realtime', pathMatch: 'full'}, { path: 'manager', component: UnitManagerComponent, canActivate: [SysAdminGuard] }, { path: 'realtime', component: UnitRealtimeComponent }, { path: 'history', component:

Can't set up routing to a named outlet in Angular

自古美人都是妖i 提交于 2021-02-10 05:31:08
问题 I have three named router outlets as shown below. ... <router-outlet name="menus"><router-outlet> <router-outlet><router-outlet> <router-outlet name="footer"><router-outlet> ... In the markup I want to route the first one, menus , to a component with certain submenu junk in it as shown in the docs. <ul *ngFor="let main of menus;" routerLink="[{outlets:{menus:[{{main.link}}]}}]" class="nav-items">{{main.header}} The error I'm getting says that: Error: Cannot match any routes. URL Segment: '%5B

Angular - Are admin files downloadable?

我的未来我决定 提交于 2021-02-08 06:46:34
问题 I have a website with Angular. I implemented the auth with jwt . I know we can prevent the user to go to the restricted routes with Angular Route Guard . Usually in SPAs all routes (html) are downloadable. Just we handle unauthorized routes in server by responding 403 code. So it's safe that user can see the html bu can't get any data. But in a specific project, we even don't want user to be able to see the html of admin panel (Since he can know about structures) Any idea? Should I use the

router navigate doesn't redirect to other page

孤街浪徒 提交于 2021-01-29 18:54:28
问题 I would redirect user to another page when he clicks on a datatable row In HTML <p-table [value]="users" selectionMode="single" [(selection)]="selectedUser" dataKey="uid" (onRowSelect)="selectedUserDetails($event)" styleClass="tab-result"> in TS file selectedUserDetails(userDetails) { console.log(userDetails); console.log("enterhere"); // is printed on console dev this.router.navigate['/userdetails']; } In module routing const routes: Routes = [ { path: "", component: AdministrationComponent,

Navigate to child route using named router outlet

那年仲夏 提交于 2021-01-29 07:34:40
问题 I have ngtabcontent so its content should be dynamic so create child routes for the PersonalComponent and Now on click of next it should navigate to its child route. const routes: { path: '', redirectTo: 'tenant', pathMatch: '{ path: "personal", component: children: [ { path: 'employer', component: AddemployerComponent, outlet: 'test'}, ] }, { path: "applicant", component: AddapplicantComponent }, { path: 'tenant', component: TenantappComponent }, { path: 'animal', component:

$routeProvider not working with html5Mode

给你一囗甜甜゛ 提交于 2021-01-28 02:21:40
问题 I just start to learn angularJs, and was trying to configure the partial page with angular route service. It worked with the hash format, however,when I tried to get rid of hash, the routeProvider stopped working. JS app.config(function($routeProvider,$locationProvider){ $locationProvider.html5Mode(true); $routeProvider.when("/", { templateUrl: "/index.html" }). when("/about", { templateUrl: "/partials/about.html" }). when("/contact", { templateUrl: "/partials/contact.html" }). otherwise({

Accessing children in auxiliary routing : Angular

*爱你&永不变心* 提交于 2021-01-28 01:07:55
问题 I have root routing defined as const routes: Routes = [{ path: '', component: HomeComponent }, { path: 'module1', loadChildren: './module1/module1.module#Module1Module' }, { path: '**', redirectTo: '' } ]; the module1.routing.ts has: const routes: Routes = [{ path: '', component: SubModule1Component, children: [{ path: 'mod1child1', component: SubMod1Child1Component }, { path: 'mod1child2', component: SubMod1Child2Component, children: [{ path: '', component: Outlet1Component, outlet: 'outlet1