angular2-routing

Issue with routerLink directive

不羁岁月 提交于 2019-12-13 16:14:29
问题 I'm writing an Angular2 app that includes some routing with the component router. As of today, I'm using angular-2.0.0-beta.3. while in a child component, I try to use the routerlink directive with the following template: <a [routerLink]=['/Home']>Go Home</a> . Instead, what's getting rendered is: <a>Go Home</a> with no exception thrown whatsoever, leaving it as an invalid anchor. It's important to note that router.navigate(['Home']) is working as expected. app.component.ts: @Component({

Angular 2 rc 1 canActivate

限于喜欢 提交于 2019-12-13 16:13:13
问题 Is there some similar like @CanActivate in the new rc router or do I have to use routerOnActivate and navigate back if it is not activable? Regards 回答1: The answer as of 15 May 2016 is that @CanActivate functionality is currently not implemented in the release candidate and other than using router-deprecated or switching to an alternate router implementation such as ngrx there really isn't anything to do other than wait. Here's an open issue asking for a solution: https://github.com/angular

Block routing if form is dirty [ Angular 2 ]

巧了我就是萌 提交于 2019-12-13 16:03:12
问题 I am blocked with this, In Angular 2, I need to block any user click event, even browser refresh if the form in the page is dirty Could you help me with ideas? 回答1: It seems you are looking for canDeactivate It allows you to block routing away. You would need a shared service where you update the forms dirty state so that the guard can access it. 回答2: The angular docs cover this exact question: https://angular.io/guide/router#candeactivate-handling-unsaved-changes I'd leave that as a comment

Angular2 RC and dynamic routes

痞子三分冷 提交于 2019-12-13 13:33:21
问题 We have a SPA app written in Angular which takes advantage of loading routes dynamically (as opposed to statically defined routes). Over time, the number of these dynamically loaded UI components will grow and grow. For any given customer deployment, we will only be using a small subset of the possible components. At runtime, the list of components will be data driven. So my desire is to take that list of components and do the following: - define an application route for each component at

Will Angular 2 child routes refresh the parent route

流过昼夜 提交于 2019-12-13 13:28:45
问题 I have an application in which I route between children of a parent route in some situations. One will look like example.com/a/1/ another example.com/a/2/ will switching from 1 to 2 trigger a reload/render of the page a ? Like playing a video in a and have a routes outlet as sibling to that video, will this change of page trigger the video to reload? If so, can this be prevented? 回答1: No, it won't. The parent component will only be refreshed if you navigate away from it and then navigate to

Angular 2 routes: resolve not called for children

泄露秘密 提交于 2019-12-13 07:28:48
问题 Using: "@angular/core": "2.2.2", "@angular/router": "3.2.2", Routes look like: export const rootRouterConfig: Routes = [ { path: '', resolve: { profile: PrefetchProfileService }, children: [ {path: '', component: Pages.LandingComponent, pathMatch: 'full'}, {path: 'pl', component: PersonalLoanComponent}, {path: 'login', component: Pages.LoginComponent, canActivate: [ExistingSessionGuard]}, {path: 'register', component: Pages.RegisterComponent, canActivate: [ExistingSessionGuard]}, {path: 'home

Angular Html5Mode PlayFramework gives 404 when refreshed

白昼怎懂夜的黑 提交于 2019-12-13 07:17:49
问题 I am setting up a Play Framework 2.5 server to use Angular 's SPA(single page App) approach and would like to use PathLocationStrategy that removes the HashTags( #example ) The page loads fine when I first hit the server, but if I refresh or come back after bookmarking it, gives 404 In the Angular documentation for Angular Router it states that server side configuration is required There's lots of info on how to do this using nginx or apache but how does one do it in Play without a proxy

Is it possible to show a notification to the user after the response from an API is returned and the user has navigated to a different page?

旧时模样 提交于 2019-12-13 05:30:17
问题 Firstly, apologies for the lack of code on this, I'm just looking for clarity on if it can be done and what APIs/libraries will allow me to do so. I have a web app front-end written in Angular. One of the back-end services it fetches data from can often take 2-3 mins to return, due to the location of the server and the nature of the data returned. Right now I have an animated spinner displayed on the front-end until the response is returned, which isn't great, as this prevents the user from

Bind query string params to model in Angular 2

 ̄綄美尐妖づ 提交于 2019-12-13 05:26:01
问题 I have an app similar to Google Maps . I would like to sync my model with query string params. What do I mean by this? Suppose you have a simple map object. You enter the site and you get default bounds set in the map component. But when you change something (pan/zoom/etc.), I want your changes to be set also in query string for location sharing things. How to do this properly? 回答1: I will show you the way I implemented it but I'm not sure if it's a proper way to do it though. The idea is:

How to use an observable in angular 2 guards' canActivate()

北慕城南 提交于 2019-12-13 04:00:51
问题 I have created an authentication guard for my angular2 rc5 application. I am also using a redux store. In that store I keep the user's authentication state. I read that the guard can return an observable or promise (https://angular.io/docs/ts/latest/guide/router.html#!#guards) I can't seem to find a way for the guard to wait until the store/observable is updated and only after that update return the guard because the default value of the store will always be false. First try: @Injectable()