angular2-routing

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

只谈情不闲聊 提交于 2019-12-05 10:27:24
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.js:3601:17\nPreActivation.prototype.setupChildRouteGuards/<@//kleinprodesign.new/angular2-app/node

angular 2 update app component from router outlet component

梦想与她 提交于 2019-12-05 10:26:41
I'm using angular 2 rc1 and the new router @angular/router In app component I have a nav section and router outlet <nav> <a *ngIf="auth?.userName == null" [routerLink]="['/login']">Login</a> <a *ngIf="auth?.userName != null" (click)="logout()">Logout</a> {{auth?.userName}} </nav> <router-outlet></router-outlet> I inject a loginService into app component and subscribe to an event in ngOnInit ngOnInit() { this.loginService.loginSuccess.subscribe(this.loginSuccess); } ngOnDestroy() { this.loginService.loginSuccess.unsubscribe(); } private loginSuccess(res: IAuthResponse) { this.auth = res; } when

How to use the Querystring instead of ';'

 ̄綄美尐妖づ 提交于 2019-12-05 08:22:10
I have been writing an internal tool for use by developers using Angular2 beta 15 backed by a C# WebApi. I up the Angular2 version as new versions are released I have been using routing from day 1 but now I need to add optional parameters. Typically this is done via the querystring. However, Angular2 includes optional parameters before the querystring like so: http://www.example.com;a=b;c=4 Originally I figured that would be fine, even though it isn't what I am used to. However, I have now run into cases where I need to have "potentially dangerous Request.Path value[s]" such as "*" (for saving

Angular2 Safari Back Button

六月ゝ 毕业季﹏ 提交于 2019-12-05 08:16:37
In the actual Angular2 beta 14 (and before) there seems to be an issue with the back button (when using routing, and several views) on Safari (actually using 9.1): https://github.com/angular/angular/issues/7722 I also experienced this problem, while this works fine e.g. on Chrome. I'm looking for a workaround until the issue is fixed? Gary Batterbee On "angular2": "2.0.0-beta.14" I had to run the tick inside a zone to get it to work for me. import {ApplicationRef, <anything else you need>} from 'angular2/core'; import {Router,<anything else you need>} from 'angular2/router'; export class

Angular 2: Route generator for '…' was not included in parameters passed

倖福魔咒の 提交于 2019-12-05 07:40:51
So I've got the following piece of code inside my AuthenticationService. After login credentials are checked, the user get's redirected to their profile: authentication.service.ts : redirectUser(username:string):void { // Redirect user to profile on successful login this.router.navigate(['../Profile/Feed', {username: username}]); } And it all worked fine, but ever since I introduced some child routes inside the ProfileComponent , I ran into some errors. First of all, this is my AppComponent with the RouteConfig: app.ts : import {Component, ViewEncapsulation} from 'angular2/core'; import

Installing Angular 2 RC2 w/ new component router

橙三吉。 提交于 2019-12-05 07:31:33
I'm probably missing something simple, but trying to use the new Component Router I can't get VS Code to recognize it. I changed all my @angular references in package.json to 2.0.0-rc.2 ; ran npm install and VS Code doesn't like my imports: When I navigate to the @angular/router folder in node_modules , and inspect the index.d.ts I see all the references for the RC1 router. Removed the @angular folder and installed again, same result. For the new release of angular rc2. The version of router to install is "@angular/router" : "3.0.0-alpha.6" or "@angular/router" : "3.0.0-alpha.7" The repo for

Angular 2 Router not working with multiple parameters passed

限于喜欢 提交于 2019-12-05 06:11:46
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-center/:id', component: CrisisDetailComponent } //-- this is working { path: 'crisis-center/:id /:id2',

Why doesn't this route match when navigating to it directly?

喜欢而已 提交于 2019-12-05 05:24:53
For the record: This is using the currently rather new "@angular/router": "3.0.0-alpha.8" , the route definitions are at the bottom of the post. When attempting to navigate in my application the behaviour is different depending on whether I enter the URL directly or following a link: Works: Entering http://localhost:9292 in the address-bar, correctly forwards to http://localhost:9292/about Works: Navigating directly to http://localhost:9292/about via the address-bar Works: If I navigate to http://localhost:9292/about/projects via an <a> tag, in the context of the FrontComponent and the

how to route using subdomain in angular2?

匆匆过客 提交于 2019-12-05 04:04:19
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. This can easily be done, but not with Angular (or any other JavaScript router for that matter). Routing to a

HashLocationStrategy does not produce # locations when routing?

て烟熏妆下的殇ゞ 提交于 2019-12-05 04:00:46
I'm running the Angular 2 beta.0 and I'm messing around with routing. Here's what I have AppComponent: import {Component, provide} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; import {FORM_DIRECTIVES, CORE_DIRECTIVES} from 'angular2/common'; import {Http, Response, HTTP_PROVIDERS} from 'angular2/http'; import {RouteConfig, Location, LocationStrategy, HashLocationStrategy, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from 'angular2/router'; import {HomeComponent} from './components/home'; import {RowsComponent} from './components/rows'; import {ColumnsComponent} from '.