angular2-routing

Angular2: data binding with routing children

别说谁变了你拦得住时间么 提交于 2019-12-11 01:37:49
问题 I have a simple setup. I'm using a routing component with multiple child components which are loaded dynamically depending on the route. I'd like for some of these child components to have data-binding with its routing parent. I'll add an @Output() property to the child, but how can I make the routing parent listen for the events that this event-emitter emits? Normally in a template with a statically defined component I'll do something like this: <child (myevent)="handleEvent($event)"> and

Angular 2 RC5 get intended route in canDeactivate

孤人 提交于 2019-12-11 01:35:08
问题 Is it possible to get the intended route in the CanDeactivate guard in Angular 2 RC5 router? I see an answer to a similar question about CanActivate (CanActivate), but that does not seem to work in the CanDeactivate guard. The use case I have is as follows: User clicks on a "Home" link while in the middle of filling out a form serviced by a "FormComponent". The FormComponent has a CanDeactivate attached to it. I need to know that the user was attempting to go specifically to the "Home" route

what is the benefit of using multiple modules in Angular2 apart from simplicity in designing? [closed]

天大地大妈咪最大 提交于 2019-12-11 01:34:02
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Will it help to reduce the loading time?(like by loading only current module to client's device? ) what I understand is that... It will increase the number of request between server and client? It will increase the complexity of your code.(Since you need to take care of

How to have nested routerLink in Angular

扶醉桌前 提交于 2019-12-11 01:08:20
问题 I have a project in angular 7 I have router links with <a> tag, and I have nested <a> tags that both have routerLink property, the issue I am facing is , the inner <a> route doesn't work <a [routerLink]="[ './comp1']"> Comp1 <a [routerLink]="['./comp2']"> Navigate to comp2 (Nested) </a> </a> this is working if I separate it <div> <a [routerLink]="['./comp2']"> Navigate to comp2 (Not Nested) </a> </div> Also I tried the below code and still same <a [routerLink]="[ './comp1']"> Comp1 <a

Where is the lazy quoted route in Angular 2?

时光毁灭记忆、已成空白 提交于 2019-12-11 00:32:18
问题 I've watched this clarifying keynote in which Papa Misko presents the new routing system introduced in the RC version. It's contained in the presentation the solution for the "Last Lazy Loading Puzzle Piece" , and that relies on quoting the route component name as shown in his own example: {path: 'simple', component: SimpleCmp} // Non-lazy route {path: 'simple', component: 'SimpleCmp'} // Lazy route But its not working to me! The typescript compiler is complaining though. Here is the error:

Multiple Components from Same Lazy Route Not Working

泪湿孤枕 提交于 2019-12-10 23:17:56
问题 Question - can I have multiple routes point to the same lazy loaded module (and associated router?). I keep getting "Error: Cannot match any routes: 'Page30'". Here is my app.routing.ts that sets up the lazy loading: const appRoutes: Routes = [ { path: '', component: Page1Component }, // <-- default page { path: 'Page1', component: Page1Component }, { path: 'Page2', component: Page2Component }, { path: 'Page3', component: Page3Component }, { path: 'Page30', loadChildren: './+lazy/lazy.module

Importing angular component to be available in all modules

血红的双手。 提交于 2019-12-10 22:35:37
问题 I've recently started playing with angular 2 and my experience so far is awesome. I have some good experience with ng1 and React as well. So, this is more of a general question and a confusion as well. I am pretty sure this would help out a lot of other people as well as I haven't really found any direct answer to this. So let's say I have this module protected.module.ts where I have some components registered. So, in order to use primitive directives ngFor, ngIf I would have to import

Passing type-safe route data to routes in angular 2

邮差的信 提交于 2019-12-10 21:00:02
问题 In my routing module I am passing data in this fashion. const routes: Routes = [ { path: '', redirectTo: 'login', pathMatch: 'full' }, { path: 'login', component: LoginComponent, data: { ShowTopBar: true, showSideBar: false} }, { path: 'error', component: ErrorComponent, data: { ShowTopBar: true, showSideBar: false}} ]; export const AppRoutingModule: ModuleWithProviders = RouterModule.forRoot(routes); In order to make the data type safe I have created a RouteData class which would hold the

Component does not have route configuration - nested routes angular2 RC1

吃可爱长大的小学妹 提交于 2019-12-10 19:52:19
问题 I have nested routes. @Routes([ { path: "/", component: RootComponent }, { path: "/parent", component: ParentComponent }]) Second level route has parameters. @Routes([ { path: "/:id", component: ChildComponent }, { path: "/child/:id", component: ChildComponent }]) //same component When I navigate with RouterLink: ['/parent/child/1'] I'm getting error: Component 'ChildComponent' does not have route configuration. If I change nested route to one level (flat) route: @Routes([ { path: "/",

Uncaught Error: Module build failed: Error: No PostCSS Config found in: \ng2-admin\node_modules\bootstrap-loader at Error (native)

醉酒当歌 提交于 2019-12-10 18:56:45
问题 I have clone ng2-admin directory from git hub few days back and run npm install after that i am able to run and see the UI, now I had been deleted node_modules folder, docs folder, and dist folder from ng2-admin now facing below error in browser console with scattered UI. So how to fix below error, ` Uncaught Error: Module build failed: Error: No PostCSS Config found in: D:\ng2-admin\node_modules\bootstrap-loader at Error (native) at D:\ng2-admin\node_modules\postcss-load-config\index.js:51