angular2-routing

Angular 2 event when any [routerLink] is clicked

ⅰ亾dé卋堺 提交于 2019-12-21 07:30:49
问题 I have a simple Loader Service that hides and shows certain loaders. I'm working on something that will be used a lot with slow connections and I need to show/hide a loader between route changes. I can hide the loader when the new route is loaded with the following. this._Router.subscribe(() => { this._LoaderService.hide(); }) I'm trying to find a way that I can call my this._LoaderService.show() function immediately when any [routerLink] is clicked (at the start of the route change, not the

How should I configure the base href for Angular 2 when using Electron?

断了今生、忘了曾经 提交于 2019-12-21 06:58:05
问题 I need to either set <base> in the HTML or APP_BASE_HREF during the bootstrap for Angular 2 to not throw exceptions. If I set either of these then Electron , thinking in terms of the file system, throws exceptions in browser_adapter.ts when trying to match a route: EXCEPTION: Error: Uncaught (in promise): Cannot match any routes. Current segment: 'C:'. Available routes: ['/dashboard', '/accounts']. I tried using just the HashLocationStrategy mentioned in this blog post, but Angular still

How to specify auxiliary component for child route in angular2 router3

≯℡__Kan透↙ 提交于 2019-12-21 06:24:13
问题 I am using the new route3 and would like to know what is the URL syntax to specify a auxiliary component for a child route. I have following child route definition: const router: RouterConfig = [ { path: 'component-c', component: ComponentC, children: [ { path: 'auxPath', component: ComponentAux, outlet: 'aux'}, { path: 'c1', component: ComponentC1 } ] } ]; And the template for ComponentC is like @Component({ selector: 'component-c', template: ` <div>Child Route Component</div> <router-outlet

How to specify auxiliary component for child route in angular2 router3

血红的双手。 提交于 2019-12-21 06:24:05
问题 I am using the new route3 and would like to know what is the URL syntax to specify a auxiliary component for a child route. I have following child route definition: const router: RouterConfig = [ { path: 'component-c', component: ComponentC, children: [ { path: 'auxPath', component: ComponentAux, outlet: 'aux'}, { path: 'c1', component: ComponentC1 } ] } ]; And the template for ComponentC is like @Component({ selector: 'component-c', template: ` <div>Child Route Component</div> <router-outlet

Angular 4 app is not working on first load in microsoft edge and ie11

岁酱吖の 提交于 2019-12-21 06:01:15
问题 I have been working on an angular 4 app. It is working fine on Mozilla and chrome but when we access it on the Microsoft edge browser, on the first load, it is not working and there is no error in the console. But when I refresh the page then it works fine. I don't understand the problem. If anybody knows about this please let me know. I have used the following dependencies in my app: "dependencies": { "@agm/core": "1.0.0-beta.0", "@angular/animations": "^4.3.2", "@angular/common": "^4.2.2",

RC.5 throws "Cannot find 'default' when lazy loading module with routes

与世无争的帅哥 提交于 2019-12-21 03:42:34
问题 tried to lazy load a module in an angular2 rc. app. This module contains routes itself. The app is trying to lazy load the module on clicking the route it is registered on but immediately throws Error: Uncaught (in promise): Error: Cannot find 'default' in './app/test/test.module' Routes in app are defined like: export const routes: Routes = [ { path: '', component: StartComponent }, { path: 'route1', component: Route1Component }, { path: 'test', loadChildren: './app/test/test.module'}, {

Error: Cannot match any routes. URL Segment: - Angular 2

穿精又带淫゛_ 提交于 2019-12-21 03:15:08
问题 I am new to angular2. I am trying to understand how to use multiple <router-outlets> in a particular template. I have gone though many QA here but couldn't resolve my error. router.module.ts const routes: Routes = [ { path: '', redirectTo: 'one', pathMatch: 'full' }, { path: 'two', component: ClassTwo, children: [ { path: 'three', component: ClassThree, outlet: 'nameThree', }, { path: 'four', component: ClassFour, outlet: 'nameFour' } ] },]; component1.html <h3>In One</h3> <nav> <a routerLink

Executing resolvers one after the other in Angular 2+

↘锁芯ラ 提交于 2019-12-20 12:29:13
问题 Given the following route: path: '', component: MyComponent, resolve: { foo: FooResolver, bar: BarResolver } Is there any way of telling angular to execute the first resolver FooResolver , and only execute the second resolver BarResolver once the first one has finished? 回答1: Resolvers are resolved in parallel. If Foo and Bar are supposed to be resolved in series they should be a single FooBar resolver. If they are supposed to be used by themselves in other routes, FooBar can wrap Foo and Bar

Retrieving a data property on an Angular2 route regardless of the level of route nesting using ActivatedRoute

给你一囗甜甜゛ 提交于 2019-12-20 12:28:24
问题 I have defined a number of routes as follows: export const AppRoutes: Routes = [ {path: '', component: HomeComponent, data: {titleKey: 'homeTitle'}}, {path: 'signup', component: SignupComponent, data: {titleKey: 'SIGNUP_FORM.TITLE'}}, {path: 'signin', component: SigninComponent, data: {titleKey: 'SIGNIN_FORM.TITLE'}}, {path: 'sendpasswordresetinformation', component: SendPasswordResetInformationComponent}, {path: 'password/reset/:userAccountToken', component: PasswordResetComponent}, { path:

Angular2 - How to best handle expired authentication token?

人走茶凉 提交于 2019-12-20 11:59:23
问题 I am using Angular 2.1.2. I have an authentication token (using angular2-jwt) and if it expires my webApi call fails with a 401 error. I am looking for a solution where the user will not lose any input data. I can catch this 401 and open a modal with the login. The user then logs in, the modal goes away, and they see their input screen. However, the failed requests are showing errors so I need to reprocess the requests. If it was a router navigate the initial data has not loaded. I could