angular2-routing

Angular2 adds true to empty query parameters

寵の児 提交于 2019-12-24 06:38:25
问题 When navigating to a url like this: /some/url;page=1;q= The url gets automatically changed to: /some/url;page=1;q=true Is it possible to disable this so that i could have an empty parameter? 回答1: I've been having the same issue in my application and so far, the only thing that has worked for me is removing the empty url parameter entirely. So if this is the url /some/url;page=1;q= when you check the url params, if q === '' , you can remove q from the object with delete() to get this /some/url

Angular2 - app.module routing: blank path not redirecting to component

喜你入骨 提交于 2019-12-24 06:34:30
问题 I've added a login feature to my app. When someone navigates to the URL with a blank path(http://example.com), I want the HomeComponent to show up which will activate the AuthGuard, but keep the URL path blank. I am still testing locally, so that may be the issue? I'm not sure. Whats happening now - when I navigate to localhost:3000/ I get nothing, just a blank screen. When I navigate to localhost:3000/home, I get my HomeComponent to show with no issue but I would like the HomeComponent to be

Angular2 default active link on site load

拥有回忆 提交于 2019-12-24 05:01:18
问题 I'm using angular2 and angular2 [routerLinkActive] on each link, to set the active link. This all works fine. When the user clicks on a link, the route becomes active and the link gets the "active" class injected and I can style accordingly. However in the route setup I set up a default route like so: const routes: Routes = [ { path: '', redirectTo: 'gettiingstarted', pathMatch: 'full' }, This works in as far as the page now successfully loads the "gettingstarted" component when the user

Angular2 default active link on site load

人走茶凉 提交于 2019-12-24 05:01:09
问题 I'm using angular2 and angular2 [routerLinkActive] on each link, to set the active link. This all works fine. When the user clicks on a link, the route becomes active and the link gets the "active" class injected and I can style accordingly. However in the route setup I set up a default route like so: const routes: Routes = [ { path: '', redirectTo: 'gettiingstarted', pathMatch: 'full' }, This works in as far as the page now successfully loads the "gettingstarted" component when the user

document.referrer is always blank in angular 2

你离开我真会死。 提交于 2019-12-24 02:33:00
问题 I am trying two scenarios: 1. Redirection can take place from an external site to one of the pages of my site. I am trying to capture the external site name using document.referrer after this redirection, but it is empty. [ NOTE- I am redirected after Azure AD authentication.] Within my site ( post authentication - to be clear). I redirect from one page to another . And on the next page I am trying to get previous page URL by document.referrer. But here again, it comes as blank. Please

Cannot find primary outlet to load 'XYZComponent'

我是研究僧i 提交于 2019-12-24 02:05:08
问题 I've got ng2 code loading in a .Net MVC component but the following error displays in the console: EXCEPTION: Uncaught (in promise): Error: Cannot find primary outlet to load 'UsersComponent' Error: Cannot find primary outlet to load 'UsersComponent' Any idea what the issue might be? I'm using ng2-final and my app does work. However, I've been asked to dev a reference implementation so I need to make sure that errors don't display in the console after the page loads. 回答1: This error usually

Angular 2: TypeError: Cannot read property 'isRouteActive' of undefined in

落花浮王杯 提交于 2019-12-24 01:27:52
问题 I am trying to use isRouteActive function to switch the active class of the li elements upon clicking the links contained within them, but it keeps giving me the errors like TypeError: Cannot read property 'isRouteActive' of undefined in [isRouteActive(['./Home']) in AppComponent@6:16] . The file looks like the following: import {Component} from 'angular2/core'; import {ROUTER_DIRECTIVES, RouteConfig, Router } from 'angular2/router'; import {FORM_PROVIDERS, FORM_DIRECTIVES, Control} from

Angular 2 rc4 can not go to page by typing the url to the address bar

倖福魔咒の 提交于 2019-12-24 00:58:15
问题 I 've just update my project to version rc 4 and got the problem. When I use the systemjs to config my project, everything is ok. When I run the project with webpack (I am using the angular2-webpack-starter ) the project was run successfully, no bugs. I can go to every link which was config by [routerLink]. But with the same link if I type the url to the browser's address bar. There was nothing happened. My app did not load anything. Here is some screen shot from my project: Screen shot Can

Angular 2: Using a component in two diffrent ways: as target of a route and by selector <selector-my-component>

大城市里の小女人 提交于 2019-12-24 00:57:43
问题 This is a general question concerning Angular 2 (no source code here) In Angular2 components can be assigned as the target of a specific route of the router. The route /something/:myId might activate the "SomethingComponent". Meanwhile components can be pulled into other components by referencing the selector in the template like this: <something-component [myId]="'123'"></something-component> Is it ok to use one component in both ways? Can I distinguish within the component, how it was

Managing user authenticated state on manual URL navigation

心不动则不痛 提交于 2019-12-24 00:33:52
问题 I'm using Angular2 with ASP.NET Core MVC and managing manual URL navigation works fine, the server is loading my Home view with Angular2 successfully. On user authentication, I'm setting up a session variable like this : HttpHelper.HttpContext.Session.SetString("isLoggedIn", true.ToString() ); What I want is that after the user is in the application, if somewhat he wants to load a specific route by manually navigating to it, I want my service to call my ASP Controller to check if the user