Angular routing strategy not behaving as expectedAngular 2 Routing Does Not Work When Deployed to Http ServerLazy Load to route other than empty route in Angular 2Angular 4 ERROR Error: Uncaught (in promise): RangeError: Maximum call stack size exceededAngular4 multiple modules issueerror TS2707 : Generic type 'MatDialogRef<T,R>' requiers between 1 and 2 argumentsrouting navigate method not redirecting to targeted componentAngular loadChildren property absolute path to module is not working$Injector Error on Angular Upgrade from 1.6.6 to 6Core module component and Shared module implementation in angular
How to say "quirky" in German without sounding derogatory?
Mean π: Archimedes vs. Gauss - π computation through generalized means
How is Team Scooby Doo (Mystery Inc.) funded?
How to work with a technician hired with a grant who argues everything
Is English tonal for some words, like "permit"?
Might have gotten a coworker sick, should I address this?
Does an oscilloscope subtract voltages as phasors?
Relocation error, error code (127) after last updates
Why is the Digital 0 not 0V in computer systems?
I asked for a graduate student position from a professor. He replied "welcome". What does that mean?
Why island and not light?
Do ibuprofen or paracetamol cause hearing loss?
Is there an inconsistency about Natasha Romanoff's middle name in the MCU?
I was promised a work PC but still awaiting approval 3 months later so using my own laptop - Is it fair to ask employer for laptop insurance?
Is low emotional intelligence associated with right-wing and prejudiced attitudes?
Are Democrats more likely to believe Astrology is a science?
Writing a love interest for my hero
Parallel resistance in electric circuits
What was the relationship between Einstein and Minkowski?
Do all humans have an identical nucleotide sequence for certain proteins, e.g haemoglobin?
Are there any non-WEB re-implementation of TeX Core in recent years?
What exactly is a marshrutka (маршрутка)?
What is this unknown executable on my boot volume? Is it Malicious?
How do email clients "send later" without storing a password?
Angular routing strategy not behaving as expected
Angular 2 Routing Does Not Work When Deployed to Http ServerLazy Load to route other than empty route in Angular 2Angular 4 ERROR Error: Uncaught (in promise): RangeError: Maximum call stack size exceededAngular4 multiple modules issueerror TS2707 : Generic type 'MatDialogRef<T,R>' requiers between 1 and 2 argumentsrouting navigate method not redirecting to targeted componentAngular loadChildren property absolute path to module is not working$Injector Error on Angular Upgrade from 1.6.6 to 6Core module component and Shared module implementation in angular
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Using the new angular lazy routing strategy, I'm expecting the following scenario to work, however, it always assumes the routes don't exist.
Taken that I have one sub-directory in my application, called /admin with various view I'd like to render, for example, /admin/settings, /admin/action-centre, etc.
Normally, the routing would be /admin/route, however, for my strategy, I don't want to move my routes into app-routing.module.ts, rather, contain the routes for /admin within the admin-routing.module.ts file.
Then, in app-routing.module.ts, I'm applying a fallback '**' to an error view, should the routes not be found.
If I remove the '**' fallback, the routes work, however, the app always assumes my routes don't exist, within admin, and fails.
admin-routing.module.ts
import NgModule from '@angular/core';
import Routes, RouterModule from '@angular/router';
import SettingsComponent from 'app/admin/settings/settings.component';
const routes: Routes = [
path: 'settings',
component: SettingsComponent,
canActivate: [AuthRequiredGuard]
];
@NgModule(
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
)
export class AdminRoutingModule
admin.module.ts
import NgModule from '@angular/core';
import AdminRoutingModule from './admin-routing.module';
import CommonModule from '@angular/common';
import SettingsComponent from './settings/settings.component';
@NgModule(
declarations: [
SettingsComponent
],
imports: [
AdminRoutingModule,
CommonModule,
],
providers: [],
entryComponents: [],
)
export class AdminModule
app-routing.module.ts
import NgModule from '@angular/core';
import Routes, RouterModule from '@angular/router';
import AuthRequiredGuard from './guards/auth-required.guard';
import RouteManagerComponent from './route-manager/route-manager.component';
import ErrorsComponent from './errors/errors.component';
const routes: Routes = [
path: '',
redirectTo: 'redirect',
pathMatch: 'full'
,
path: 'redirect',
component: RouteManagerComponent,
canActivate: [AuthRequiredGuard]
,
path: '**',
component: ErrorsComponent
];
@NgModule(
imports: [RouterModule.forRoot(routes,
paramsInheritanceStrategy: 'always',
enableTracing: true
)],
exports: [RouterModule]
)
export class AppRoutingModule
app.module.ts
import BrowserModule from '@angular/platform-browser';
import NgModule, Injector, ErrorHandler from '@angular/core';
import HttpModule from '@angular/http';
import HttpClientModule, HTTP_INTERCEPTORS from '@angular/common/http';
import BrowserAnimationsModule from '@angular/platform-browser/animations';
import AppRoutingModule from './app-routing.module';
import AppComponent from './app.component';
import AppInjector from 'app/appinjector.module';
import AdminModule from 'app/admin/admin.module';
import HttpInterceptorModule from './interceptors/http-interceptor.module';
import AuthRequiredGuard from 'app/guards/auth-required.guard';
import ErrorsComponent from './errors/errors.component';
import CustomErrorHandler from './custom-error-handler';
@NgModule(
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
HttpModule,
AppRoutingModule,
AdminModule
],
providers: [
AuthRequiredGuard,
provide: ErrorHandler,
useClass: CustomErrorHandler
],
bootstrap: [AppComponent]
)
export class AppModule
constructor(injector: Injector)
AppInjector.setInjector(injector);
angular
add a comment
|
Using the new angular lazy routing strategy, I'm expecting the following scenario to work, however, it always assumes the routes don't exist.
Taken that I have one sub-directory in my application, called /admin with various view I'd like to render, for example, /admin/settings, /admin/action-centre, etc.
Normally, the routing would be /admin/route, however, for my strategy, I don't want to move my routes into app-routing.module.ts, rather, contain the routes for /admin within the admin-routing.module.ts file.
Then, in app-routing.module.ts, I'm applying a fallback '**' to an error view, should the routes not be found.
If I remove the '**' fallback, the routes work, however, the app always assumes my routes don't exist, within admin, and fails.
admin-routing.module.ts
import NgModule from '@angular/core';
import Routes, RouterModule from '@angular/router';
import SettingsComponent from 'app/admin/settings/settings.component';
const routes: Routes = [
path: 'settings',
component: SettingsComponent,
canActivate: [AuthRequiredGuard]
];
@NgModule(
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
)
export class AdminRoutingModule
admin.module.ts
import NgModule from '@angular/core';
import AdminRoutingModule from './admin-routing.module';
import CommonModule from '@angular/common';
import SettingsComponent from './settings/settings.component';
@NgModule(
declarations: [
SettingsComponent
],
imports: [
AdminRoutingModule,
CommonModule,
],
providers: [],
entryComponents: [],
)
export class AdminModule
app-routing.module.ts
import NgModule from '@angular/core';
import Routes, RouterModule from '@angular/router';
import AuthRequiredGuard from './guards/auth-required.guard';
import RouteManagerComponent from './route-manager/route-manager.component';
import ErrorsComponent from './errors/errors.component';
const routes: Routes = [
path: '',
redirectTo: 'redirect',
pathMatch: 'full'
,
path: 'redirect',
component: RouteManagerComponent,
canActivate: [AuthRequiredGuard]
,
path: '**',
component: ErrorsComponent
];
@NgModule(
imports: [RouterModule.forRoot(routes,
paramsInheritanceStrategy: 'always',
enableTracing: true
)],
exports: [RouterModule]
)
export class AppRoutingModule
app.module.ts
import BrowserModule from '@angular/platform-browser';
import NgModule, Injector, ErrorHandler from '@angular/core';
import HttpModule from '@angular/http';
import HttpClientModule, HTTP_INTERCEPTORS from '@angular/common/http';
import BrowserAnimationsModule from '@angular/platform-browser/animations';
import AppRoutingModule from './app-routing.module';
import AppComponent from './app.component';
import AppInjector from 'app/appinjector.module';
import AdminModule from 'app/admin/admin.module';
import HttpInterceptorModule from './interceptors/http-interceptor.module';
import AuthRequiredGuard from 'app/guards/auth-required.guard';
import ErrorsComponent from './errors/errors.component';
import CustomErrorHandler from './custom-error-handler';
@NgModule(
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
HttpModule,
AppRoutingModule,
AdminModule
],
providers: [
AuthRequiredGuard,
provide: ErrorHandler,
useClass: CustomErrorHandler
],
bootstrap: [AppComponent]
)
export class AppModule
constructor(injector: Injector)
AppInjector.setInjector(injector);
angular
add a comment
|
Using the new angular lazy routing strategy, I'm expecting the following scenario to work, however, it always assumes the routes don't exist.
Taken that I have one sub-directory in my application, called /admin with various view I'd like to render, for example, /admin/settings, /admin/action-centre, etc.
Normally, the routing would be /admin/route, however, for my strategy, I don't want to move my routes into app-routing.module.ts, rather, contain the routes for /admin within the admin-routing.module.ts file.
Then, in app-routing.module.ts, I'm applying a fallback '**' to an error view, should the routes not be found.
If I remove the '**' fallback, the routes work, however, the app always assumes my routes don't exist, within admin, and fails.
admin-routing.module.ts
import NgModule from '@angular/core';
import Routes, RouterModule from '@angular/router';
import SettingsComponent from 'app/admin/settings/settings.component';
const routes: Routes = [
path: 'settings',
component: SettingsComponent,
canActivate: [AuthRequiredGuard]
];
@NgModule(
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
)
export class AdminRoutingModule
admin.module.ts
import NgModule from '@angular/core';
import AdminRoutingModule from './admin-routing.module';
import CommonModule from '@angular/common';
import SettingsComponent from './settings/settings.component';
@NgModule(
declarations: [
SettingsComponent
],
imports: [
AdminRoutingModule,
CommonModule,
],
providers: [],
entryComponents: [],
)
export class AdminModule
app-routing.module.ts
import NgModule from '@angular/core';
import Routes, RouterModule from '@angular/router';
import AuthRequiredGuard from './guards/auth-required.guard';
import RouteManagerComponent from './route-manager/route-manager.component';
import ErrorsComponent from './errors/errors.component';
const routes: Routes = [
path: '',
redirectTo: 'redirect',
pathMatch: 'full'
,
path: 'redirect',
component: RouteManagerComponent,
canActivate: [AuthRequiredGuard]
,
path: '**',
component: ErrorsComponent
];
@NgModule(
imports: [RouterModule.forRoot(routes,
paramsInheritanceStrategy: 'always',
enableTracing: true
)],
exports: [RouterModule]
)
export class AppRoutingModule
app.module.ts
import BrowserModule from '@angular/platform-browser';
import NgModule, Injector, ErrorHandler from '@angular/core';
import HttpModule from '@angular/http';
import HttpClientModule, HTTP_INTERCEPTORS from '@angular/common/http';
import BrowserAnimationsModule from '@angular/platform-browser/animations';
import AppRoutingModule from './app-routing.module';
import AppComponent from './app.component';
import AppInjector from 'app/appinjector.module';
import AdminModule from 'app/admin/admin.module';
import HttpInterceptorModule from './interceptors/http-interceptor.module';
import AuthRequiredGuard from 'app/guards/auth-required.guard';
import ErrorsComponent from './errors/errors.component';
import CustomErrorHandler from './custom-error-handler';
@NgModule(
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
HttpModule,
AppRoutingModule,
AdminModule
],
providers: [
AuthRequiredGuard,
provide: ErrorHandler,
useClass: CustomErrorHandler
],
bootstrap: [AppComponent]
)
export class AppModule
constructor(injector: Injector)
AppInjector.setInjector(injector);
angular
Using the new angular lazy routing strategy, I'm expecting the following scenario to work, however, it always assumes the routes don't exist.
Taken that I have one sub-directory in my application, called /admin with various view I'd like to render, for example, /admin/settings, /admin/action-centre, etc.
Normally, the routing would be /admin/route, however, for my strategy, I don't want to move my routes into app-routing.module.ts, rather, contain the routes for /admin within the admin-routing.module.ts file.
Then, in app-routing.module.ts, I'm applying a fallback '**' to an error view, should the routes not be found.
If I remove the '**' fallback, the routes work, however, the app always assumes my routes don't exist, within admin, and fails.
admin-routing.module.ts
import NgModule from '@angular/core';
import Routes, RouterModule from '@angular/router';
import SettingsComponent from 'app/admin/settings/settings.component';
const routes: Routes = [
path: 'settings',
component: SettingsComponent,
canActivate: [AuthRequiredGuard]
];
@NgModule(
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
)
export class AdminRoutingModule
admin.module.ts
import NgModule from '@angular/core';
import AdminRoutingModule from './admin-routing.module';
import CommonModule from '@angular/common';
import SettingsComponent from './settings/settings.component';
@NgModule(
declarations: [
SettingsComponent
],
imports: [
AdminRoutingModule,
CommonModule,
],
providers: [],
entryComponents: [],
)
export class AdminModule
app-routing.module.ts
import NgModule from '@angular/core';
import Routes, RouterModule from '@angular/router';
import AuthRequiredGuard from './guards/auth-required.guard';
import RouteManagerComponent from './route-manager/route-manager.component';
import ErrorsComponent from './errors/errors.component';
const routes: Routes = [
path: '',
redirectTo: 'redirect',
pathMatch: 'full'
,
path: 'redirect',
component: RouteManagerComponent,
canActivate: [AuthRequiredGuard]
,
path: '**',
component: ErrorsComponent
];
@NgModule(
imports: [RouterModule.forRoot(routes,
paramsInheritanceStrategy: 'always',
enableTracing: true
)],
exports: [RouterModule]
)
export class AppRoutingModule
app.module.ts
import BrowserModule from '@angular/platform-browser';
import NgModule, Injector, ErrorHandler from '@angular/core';
import HttpModule from '@angular/http';
import HttpClientModule, HTTP_INTERCEPTORS from '@angular/common/http';
import BrowserAnimationsModule from '@angular/platform-browser/animations';
import AppRoutingModule from './app-routing.module';
import AppComponent from './app.component';
import AppInjector from 'app/appinjector.module';
import AdminModule from 'app/admin/admin.module';
import HttpInterceptorModule from './interceptors/http-interceptor.module';
import AuthRequiredGuard from 'app/guards/auth-required.guard';
import ErrorsComponent from './errors/errors.component';
import CustomErrorHandler from './custom-error-handler';
@NgModule(
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
HttpModule,
AppRoutingModule,
AdminModule
],
providers: [
AuthRequiredGuard,
provide: ErrorHandler,
useClass: CustomErrorHandler
],
bootstrap: [AppComponent]
)
export class AppModule
constructor(injector: Injector)
AppInjector.setInjector(injector);
angular
angular
asked Mar 28 at 9:47
PeculiarJoePeculiarJoe
264 bronze badges
264 bronze badges
add a comment
|
add a comment
|
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55394514%2fangular-routing-strategy-not-behaving-as-expected%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55394514%2fangular-routing-strategy-not-behaving-as-expected%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown