angular2-modules

How to dynamically load external angular 2 module (like served from an external module.bundle.js)

心已入冬 提交于 2019-12-03 03:06:08
I can dynamically load local modules as someone else did in the plunker here . But how do I load an external module, lets say from a separate bundle js served by another service. In the example plunker, src/app.ts has: constructor(private viewref: ViewContainerRef, private resolver: ComponentFactoryResolver, private loader: SystemJsNgModuleLoader, private compiler: Compiler){ this.module = new ModuleNode(); //can I make this a non-local script reference somehow? //like to http://example.net/external.module.bundle.js this.module.modulePath = "src/dynamic.module#DynamicModule"; this.module

Angular 4.0.0 could not find bootstrap code

北城余情 提交于 2019-12-01 05:30:54
Error : Tried to find bootstrap code, but Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options. main.ts getHttp().get('/assets/config.json').toPromise() .then((res: Response) => { let conf = res.json(); platformBrowserDynamic().bootstrapModule(createAppModule(conf)); }) I am using angular-cli. With angular v2.3.1 this code was working fine. I want to fetch json and pass it to @Ngmodules providers { provide: Config, useValue: conf } If the data you are fetching from config.json are just about a configuration of an application module and you are

Angular 4.0.0 could not find bootstrap code

落爺英雄遲暮 提交于 2019-12-01 03:17:23
问题 Error : Tried to find bootstrap code, but Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options. main.ts getHttp().get('/assets/config.json').toPromise() .then((res: Response) => { let conf = res.json(); platformBrowserDynamic().bootstrapModule(createAppModule(conf)); }) I am using angular-cli. With angular v2.3.1 this code was working fine. I want to fetch json and pass it to @Ngmodules providers { provide: Config, useValue: conf } 回答1: If the

Angular2 Module: How can i import a service from another module

微笑、不失礼 提交于 2019-11-30 11:06:00
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { ClinicFacilityService } from './apiClient.module'; @NgModule({ imports: [ CommonModule, FormsModule ], declarations: [ DailyScheduleComponent, ], providers: [ ClinicFacilityService ], exports: [ DailyScheduleComponent ], }) export class ClinicDashboardModule { } I need to import ClinicFacilityService that is declared in another module ( apiClient.module ) Is this even possible, if not why is not possible. At the moment i am importing

Angular2 module has no exported member

不打扰是莪最后的温柔 提交于 2019-11-30 05:37:25
For a website with authentication in Angular2, I want to use a component of the authentication submodule in the main app component. However, I keep getting the following error: app/app.component.ts(3,10): error TS2305: Module '"<dir>/app/auth/auth.module"' has no exported member 'SigninComponent'. even after exporting SigninComponent. The project folder structure is as shown below: app/auth/auth.module.ts: import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { RegisterComponent } from './components

Angular2 Lazy Loading Service being Instantiated Twice

蹲街弑〆低调 提交于 2019-11-30 02:44:27
问题 I just switched my application over to be lazy-loaded today. I have a SharedModule that exports a bunch of services. In my AppModule , I import SharedModule because AppComponent needs access to a few of the shared services. In another module FinalReturnModule , I import SharedModule . In one of my services, I put a console.log('hi') in the constructor. When the app first loads, I get hi to the console. Whenever I navigate to a page within the FinalReturnModule I get hi again. Obviously, since

Angular2 Module: How can i import a service from another module

给你一囗甜甜゛ 提交于 2019-11-29 16:36:56
问题 import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { ClinicFacilityService } from './apiClient.module'; @NgModule({ imports: [ CommonModule, FormsModule ], declarations: [ DailyScheduleComponent, ], providers: [ ClinicFacilityService ], exports: [ DailyScheduleComponent ], }) export class ClinicDashboardModule { } I need to import ClinicFacilityService that is declared in another module ( apiClient

Angular2 Routing: import submodule with routing + making it prefixed

两盒软妹~` 提交于 2019-11-29 07:17:56
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 CountryModule {} I want to import this module with its own internal routing, but I want to make its whole routing

How to declare a directive globally for all modules in Angular?

拜拜、爱过 提交于 2019-11-29 06:14:20
问题 I'm developing a Github repo which follows the offical tutorial of Angular (Tour of Heroes). You can see all the code here: https://github.com/Ismaestro/angular7-example-app My problem, is that I have a directive declared in the main module of the app (app.module) and if I use it inside the AppComponent it works good (the directive only highlight a text inside a DOM element). But I have another module called HeroesModule within AppModule, and inside a component of this module, this directive

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-28 12:38:12
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 to change in order to provide LazyModuleService in my lazy-loaded module and have that service scoped to