angular2-routing

Angular 5 TypeError: outlet is null / cannot read property 'component' of null while routing

对着背影说爱祢 提交于 2019-12-22 06:12:05
问题 With Angular 5, I am trying to route to a projects page with an parameter id. After being on this page: /project/:projectid and routing in the header again to this page, only with an different ID, it throws: columnNumber: 27683 fileName: "//kleinprodesign.new/assets/js/predependencies/zone.min.js" lineNumber: 1 message: "Uncaught (in promise): TypeError: outlet is null\nPreActivation.prototype.setupRouteGuards@//kleinprodesign.new/angular2-app/node_modules/@angular/router/bundles/router.umd

Angular 2 Router not working with multiple parameters passed

帅比萌擦擦* 提交于 2019-12-22 05:24:18
问题 I created a sample plunker, to pass in multiple parameter to the next page and it doesn't work. Here is the plunker demonstration where crisis center routing doesn't work after click on items. http://plnkr.co/edit/ngNSsKBzAuhaP0EjKVJX?p=preview onSelect(crisis: Crisis) { // Navigate with Absolute link //this.router.navigate(['/crisis-center', 1]); //this is working. this.router.navigate(['/crisis-center', { id: '1', id2:'2'}]); //this is not working } //below is the routes: //{ path: 'crisis

how to route using subdomain in angular2?

痴心易碎 提交于 2019-12-22 04:31:58
问题 I'm looking to create an Angular 2 app with different user landing pages, for example 'user1.example-domain.com' and 'user2.example-domain.com' will have different and unrelated 'home page'. My questions: How could I do it using Angular 2? How can I test it on my local machine? is "user1.localhost:port" enough? I've tried using static routing like so: {path: 'test.localhost:4200/generic-link1', component: GenericLink1Component} I've seen it done in tumbler I know that it could be done. 回答1:

How to test if a route exists in Angular2?

丶灬走出姿态 提交于 2019-12-22 04:11:32
问题 In Angular2 how do I check if a route exists? I have a method that remembers which route to navigate to if the user is not authorised. On login I have: this.router.navigate([this.authService.redirectUrl]); But I only want to navigate IF the redirectUrl references a valid route, something like .. if (this.authService.redirectUrl is a valid route) { this.router.navigate([this.authService.redirectUrl]); } Is there any way to check this? 回答1: You can check if the route exists like that using the

Angular 2 CanActivate is called twice

拈花ヽ惹草 提交于 2019-12-22 03:51:25
问题 I am faced with a problem with route guards with Angular. My CanActivate guard is called twice when navigating to a page that is not permitted because I'm not logged in. I have 1 root module and provided there my CanActivate guard and other services. Thank you in advance! Here is my router: const appRoutes: Routes = [ { path: "", pathMatch: "full", redirectTo: "/meal-list", }, { path: "login", component: LoginComponent, }, { path: "meal-list", component: MealListComponent, canActivate:

How to setup input bindings for a component when it's created by router-outlet?

久未见 提交于 2019-12-22 03:22:49
问题 When a component is created by the router how can I setup property bindings? 回答1: It is not supported to use bindings for components added by the router. See also this discussion https://github.com/angular/angular/issues/4452 Use a shared service to communicate with components added by the router. For details see https://angular.io/docs/ts/latest/cookbook/component-communication.html 来源: https://stackoverflow.com/questions/34647918/how-to-setup-input-bindings-for-a-component-when-its-created

Angular2 lazy loading a route issue

丶灬走出姿态 提交于 2019-12-22 00:39:17
问题 Angular2 lazy loading a route issue. I'm using Angular2, typscript, html5 and systemjs. I'm trying to get lazy loading working for one of my basic routes. This is the blog I'm following but I can't seem to get it working: http://blog.angular-university.io/angular2-ngmodule/ This is the console error I get: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '500' My page is the 500 page. Below I have added my files at there current state. Module for 500 page: import { NgModule

Angular - Animation between pages (after changing route)

て烟熏妆下的殇ゞ 提交于 2019-12-21 23:53:49
问题 I'm still new to Angular 2 and was wondering if there is a way to let a component 'fly in' and let another component 'fly out' when switching routes. Let's say I have 2 components: Test1Component and Test2Component and 2 routes pointing to each of them. What would be the best way to do it? 回答1: https://github.com/angular/angular/issues/9845#issuecomment-235799008 RC5 will hopefully be out this week, if not then next week. For now (with RC5) you will need to do this for every component that is

I'm using ng2-metadata with my angular version 4 app and google only seems to show the default title and description

僤鯓⒐⒋嵵緔 提交于 2019-12-21 18:12:15
问题 I'm using ng2-metadata with my angular app and google only seems to show the default title and meta description. My tech: Angular version 4, webpack, typescript and firebase for hosting. I'm deploying an AOT build and I have added the ng2-metadata aot function like the below link suggests. This is the package I'm using: https://www.npmjs.com/package/ng2-metadata Current issue: The code seems to work in the browser visually but the google bots don't seem to show the other pages title and meta

Infinite redirect loop when issuing a router.navigate with Angular2 Router

我是研究僧i 提交于 2019-12-21 16:58:29
问题 Note Edit with relevant code snippets I have run into an odd issue where I get into a infinite redirect loop when issuing a router.navigate. Setup I use the hash location strategy and the app is used as an Outlook plugin. I have three routing rules "" redirect to "/login" "/login" mapped to LoginViewComponent "/foo" mapped to FooViewComponent The LoginViewComponent has two behaviours: If the user's identity cannot be verified the user will be prompted for credentials If not redirect is issued