angular2-modules

Angular2 router: how to correctly load children modules with their own routing rules

孤街浪徒 提交于 2019-11-28 06:46:26
here is my Angular2 app structure: Here is part of my code. The following is the main module of the Angular2 app, that imports its routing rules and a child module ( EdgeModule ) and uses some components related to some pages. app.module.ts @NgModule({ declarations: [ AppComponent, PageNotFoundComponent, LoginComponent ], imports: [ ... appRouting, EdgeModule ], providers: [ appRoutingProviders, LoginService ], bootstrap: [AppComponent] }) export class AppModule { } Here is the routing rules for the main module. It have paths to login page and page not found. app.routing.ts const appRoutes:

Angular2 Routing: import submodule with routing + making it prefixed

心不动则不痛 提交于 2019-11-28 00:54:17
问题 I have a main module and some submodules. And I want to specify some not trivial routing between them. I'd prefer defining the routes of a submodule within the submodule. E.g.: @NgModule({ imports: [ /*...*/ RouterModule.forChild([ { path: 'country', redirectTo: 'country/list' }, { path: 'country/list', component: CountryListComponent }, { path: 'country/create', component: CountryCreateComponent }, /*...*/ ]) ], declarations: [/*...*/], exports: [ RouterModule, ], }) export class

How to route to a Module as a child of a Module - Angular 2 RC 5

好久不见. 提交于 2019-11-27 17:04:48
I am in the process upgrading an application I'm working on to the latest Angular 2 release candidate. As part of this work I am attempting to use the NgModule spec and migrating all of the parts of my application to modules. For the most part, this has gone very well with the exception of an issue with routing. "@angular/common": "2.0.0-rc.5", "@angular/compiler": "2.0.0-rc.5", "@angular/core": "2.0.0-rc.5", "@angular/forms": "0.3.0", "@angular/http": "2.0.0-rc.5", "@angular/platform-browser": "2.0.0-rc.5", "@angular/platform-browser-dynamic": "2.0.0-rc.5", "@angular/router": "3.0.0-rc.1", My

How do I provide a service in a lazy-loaded module and have that service scoped to just the lazy-loaded module and its components?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 04:47:58
问题 In the angular docs FAQ section it states, "Unlike providers of the modules loaded at launch, providers of lazy-loaded modules are module-scoped." link Does 'module-scoped' here mean just the module or does it extend to include all components belonging to that module? The reason I ask is because I have a lazy-loaded module with 2 components that belong to it. I register a service in the module but for some reason each component is getting a different instance of that service. What do I need

How to share service between two modules - @NgModule in angular not between to components?

淺唱寂寞╮ 提交于 2019-11-27 03:39:16
In my application, I have two different bootstrap module ( @NgModule ) running independently in one application. There are not one angular app bit separate bootstrap module and now I want they should communicate to each other and share data. I know through @Injectable service as the provider in the module, I can share data in all component under @NgModule but how I will share data between two different module ( not component inside module ). Is there a way one service object can be accessed in another module? Is there a way I can access the object of Service available in browser memory and use

How to route to a Module as a child of a Module - Angular 2 RC 5

一个人想着一个人 提交于 2019-11-26 18:53:52
问题 I am in the process upgrading an application I'm working on to the latest Angular 2 release candidate. As part of this work I am attempting to use the NgModule spec and migrating all of the parts of my application to modules. For the most part, this has gone very well with the exception of an issue with routing. "@angular/common": "2.0.0-rc.5", "@angular/compiler": "2.0.0-rc.5", "@angular/core": "2.0.0-rc.5", "@angular/forms": "0.3.0", "@angular/http": "2.0.0-rc.5", "@angular/platform-browser

How to share service between two modules - @NgModule in angular not between to components?

↘锁芯ラ 提交于 2019-11-26 17:31:19
问题 In my application, I have two different bootstrap module ( @NgModule ) running independently in one application. There are not one angular app bit separate bootstrap module and now I want they should communicate to each other and share data. I know through @Injectable service as the provider in the module, I can share data in all component under @NgModule but how I will share data between two different module ( not component inside module ). Is there a way one service object can be accessed