Questions tagged [angular2-modules]

132 questions
15
votes
2 answers

Can't bind to FormGroup since it isn't a known property of 'form' (FormsModule, ReactiveFormsModule loaded)

I've just seen this question but I still have the same error. I have a shared module which I import to my feature module. But I also tried import FormsModule, ReactiveFormsModule modules to my feature module directly. Angular 2.0 Final version. My…
Javier RB
  • 339
  • 1
  • 3
  • 9
12
votes
3 answers

Share an external module between lazy loaded modules in angular2

My app has components that use a heavy-weight external package (ag-grid, about 1MB) that is provided as an angular2 module (AgGridModule). I would like to load this package only when the components using it are required, so my ContentModule and all…
11
votes
3 answers

Does import of unnecessary modules in AppModule slow down the Angular 2 app?

In angular(2/4/6) application if we import unnecessary modules in app module will that slow down the application. Does it impact on the performance of the application ? @NgModule({ imports: [ BrowserModule.withServerTransition({ appId: 'myId'…
Kooldandy
  • 457
  • 4
  • 12
11
votes
0 answers

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

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:…
AzureMinotaur
  • 536
  • 6
  • 21
11
votes
1 answer

Angular2 Lazy Loading Service being Instantiated Twice

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…
10
votes
1 answer

Angular2 - Directive not working when not declared in the same module

I have a directive and I want to use it in multiple modules. Declaring it on each modules produces an error. Thus, I tried to declare it in a shared module and import this shared module to other modules. However, it didn't work. It only works when…
9
votes
1 answer

Angular 2 - Exporting Auth Services from AuthModule to AppModule

I decided to put LoginComponent, AuthService, LoggedInGuard inside a module called AuthModule: import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { AuthComponent } from './auth.component'; import {…
Pasp Ruby
  • 837
  • 9
  • 21
8
votes
3 answers

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?

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…
FlashBanistan
  • 396
  • 1
  • 6
  • 20
7
votes
1 answer

Angular 2: Load different versions of the libraries based on the data

I have a requirement where I need to load different version modules based on the data. Something like monthly data, if some change happens in my module code for the current month, there shouldn't be any change in the view/logic from the previous…
7
votes
2 answers

Is nested modules bad in Angular?

There is something I wonder about modules. I started Angular 2 a while ago, so i search too many topics but I couldn't find any satisfying answer yet. When we creating angular 2 application, using modules for sure. Also use nested modules of course.…
orhun.begendi
  • 867
  • 2
  • 15
  • 31
7
votes
1 answer

Angular 2 - (SystemJS) Unexpected directive 'ViewerComponent' imported by the module 'GalleryModule'

I am getting the following error, not sure what to do: (SystemJS) Unexpected directive ViewerComponent imported by the module GalleryModule Thanks for any help relating to what might be causing the error. In the main app it is importing the…
Pete
  • 1,905
  • 3
  • 13
  • 21
7
votes
3 answers

Angular 2.0 Unexpected value '[object Object]' imported by the module 'AppModule'

When I try load my angular 2.0 application I get the following error: (index):21 Error: Error: Unexpected value '[object Object]' imported by the module 'AppModule' import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule…
Guy Gallant
  • 113
  • 1
  • 1
  • 10
6
votes
2 answers

Error: 'app-header' is not a known element: Angular 2

Below is my folder structure. app - common - header header.component.css header.component.html header.component.ts - footer footer.component.css footer.component.html …
Green Computers
  • 597
  • 2
  • 12
  • 22
6
votes
3 answers

Angular 4.0.0 could not find bootstrap code

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 =…
Rohit
  • 2,603
  • 2
  • 21
  • 44
6
votes
2 answers

Angular2 Routing: import submodule with routing + making it prefixed

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: [ /*...*/ …
Gábor Imre
  • 4,754
  • 2
  • 28
  • 44
1
2
3
8 9