angular2-routing

normalized URL strips trailing slash

北慕城南 提交于 2019-12-24 00:23:02
问题 The implementation of Location.normalize in Angular 2 strips trailing slashes from URLs (documentation). What is the reasoning behind this? Can I go ahead and override this behaviour if I wish? What are the potential consequences of doing so? I would prefer that normalized URLs have a trailing slash, in part for consistency with the API exposed by the back-end part of my project (reasoning). Edit: I see that there is a commit against angular.js which allows the configuring of this behaviour;

Closing md-sidenav when router link is selected

血红的双手。 提交于 2019-12-23 22:11:18
问题 I am working on an angular project, I've implemented angular material components like the side-nav. The side-nav has ul li elements, where the links are nested and are router links not href. my question when I select a link to go to another view, I want to make a call to side nav to toggle and close. cause it always remains open 回答1: Option 1: You can subscribe to Router events and close sidenav whenever router event takes place. Code: requires these imports: import { Component,ViewChild,

Angular2 router - Auxiliary route

∥☆過路亽.° 提交于 2019-12-23 21:41:25
问题 I do have a lazy loaded module which loads by default LazyLoadedComponent when I go to /lazy . So far, it's OK. This component contains 2 router-outlet : <router-outlet></router-outlet> <router-outlet name="aux"></router-outlet> And the module has the following routes : const routes = [ { path: '', component: LazyLoadedComponent, children: [ { path: '', component: NonAuxComponent }, { path: '', component: AuxComponent, outlet: 'aux' } ] } ]; When I go to /lazy I do have the 3 components

Access activated route data from some other component

与世无争的帅哥 提交于 2019-12-23 20:14:42
问题 We have component ( ka-cockpit-panel) which is not mapped to any route and inserted manually in the some other component as shown below : .. ... <section class="ka-cockpit-panel cockpit-1 pull-left"> <ka-cockpit-panel></ka-cockpit-panel> </section> ... .. In this component i want to access the current active route data . For eg : if we have some other component ( say ka-integration-component ) and it has some route data associated with it ( as shown below ), whenever we navigate to this

Restrict unauthorised access in Component Angular 2

Deadly 提交于 2019-12-23 17:26:47
问题 I have to prevent user to move on any route until user is logged in. Can somebody help me how can we achieve this in Angular 2 Component Routing. Thanks, 回答1: You can use the @CanActivate decorator that angular2 provides. You decorate the component that you want to restrict with a condition. More info can be found in the angular docs: https://angular.io/docs/ts/latest/guide/router-deprecated.html#!#lifecycle-hooks It has an example using a similar decorator called @CanDeactivate . This is a

Add Parameter to Angular 2 Route from Component without Navigating

柔情痞子 提交于 2019-12-23 17:18:12
问题 With my current code I am attempting to do deep linking within my Accordion component. By navigating to dev.local/#/accordion and then clicking on an accordion title, I want to update the route to look like: dev.local/#/accordion/2 But I do not want to navigate to this path once it is set. Essentially, if someone were to hypothetically copy this URL it would return them to the exact accordion that was opened when they copied it. The problem I'm running into is that I'm applying the following

Angular 2 routing not working on page refresh with Apache

我的梦境 提交于 2019-12-23 17:03:04
问题 Using Angular 2 RC 4 with the updated @angular/router, I got the route URLs to display in the browser using the answer in this question However, when I refresh or directly request a page with a route other than the default, it takes me to the default page (as if I requested index.html) rather than the routed page I want. How can I make the Angular 2 routes work correctly on a page refresh with Apache 2.4? Routes and bootstrap: const routes: RouterConfig = [ { path: '', redirectTo:

click to remove/Deactivate Auxiliary Route in angular 2

主宰稳场 提交于 2019-12-23 16:31:43
问题 When I do click on compose button to open email template (e.g; as given in gmail when click to compose mail), using Auxiliary Route for multiple template in single page. Question is : how to remove or Deactivate this Auxiliary Route, when click on cross button. app.ts @RouteConfig([ { path: '/', name: 'OpportunityList', component: OpportunityComponent, useAsDefault: true }, { path: '/detail', name: 'Detail', component: DetailComponent }, { aux: '/mailer', name: 'Mailer', component:

Angular2 keep/add trailing slash

橙三吉。 提交于 2019-12-23 16:31:16
问题 I have an issue with trailing slashes being removed by Angular2. I've setup my dotnet core application to add them, but they get removed as soon as the js get loaded in. Is it even possible in Angular2? (My client requires it, so no need to add a comment saying; don't use trailing slash). Thanks in advance. EDIT: Should have added, this is running with Angular2-Universal, so upgrading the angular version is not that easy :( 回答1: We have a website by Angular one, after we decided migrating to

Angular: Displaying target URL when resolve fails

匆匆过客 提交于 2019-12-23 15:46:15
问题 I have a simple resolver for a route like /orders/first : resolve(): Promise<Order> { return this.orderService.get() .then((response) => response.order) .catch(error => Promise.reject(error)); } I also have an error handler that redirects to an error page: this.router.navigate(['/error'], { skipLocationChange: true }); I want the URL to be /orders/first so if the user refresh he might be able to view the page. This also make back button return to an incorrect page (previous previous page) The