Questions tagged [ng-modules]

Angular NgModule is a class marked by the @NgModule decorator.

NgModules configure the injector and the compiler and help organize related things together.

An NgModule is a class marked by the @NgModule decorator. @NgModule takes a metadata object that describes how to compile a component's template and how to create an injector at runtime. It identifies the module's own components, directives, and pipes, making some of them public, through the exports property, so that external components can use them. @NgModule can also add service providers to the application dependency injectors.

Resources

192 questions
22
votes
1 answer

How to correctly import FormGroup in NgModule in Angular 2

I try to import FromGroup, FormBuilder and FormControl to my CustomModule: import { FormsModule, FormGroup } from '@angular/forms'; @NgModule({ imports: [ FormsModule, FormGroup ] }) But it throws an error: EXCEPTION: Uncaught (in…
Adrien Castagliola
  • 821
  • 2
  • 8
  • 27
19
votes
2 answers

Many Modules using the same component causes error - Angular 2

I have a shared component called GoComponent that I want to use in 2 modules: FindPageModule and AddPageModule. When I add it in the declarations of "FindPageModule" and in my "AddPageModule" I get an error: find:21 Error: (SystemJS) Type…
BeniaminoBaggins
  • 8,960
  • 28
  • 96
  • 208
15
votes
2 answers

Karma unit testing error: Unexpected value imported by the module. Please add a @NgModule annotation

I've created a fresh new component via: ng g mytest1 Then I changed the constructor line to this: constructor(private dialogRef: MatDialogRef) { } , and added the required import: import { MatDialogRef } from…
MrProgrammer
  • 449
  • 1
  • 5
  • 16
13
votes
5 answers

What is @NgModule actually in Angular?

I am new to Angular 2. What is @NgModule actually in Angular 2? I referred through the official documentation by the Angular. But I didn't have any clarity.
manohar
  • 141
  • 1
  • 1
  • 4
13
votes
4 answers

What kind of code we write inside class declared under ngModule decorator?

I am just starting to learn Angular. I have come across several examples using ngModule decorators over an empty class. What I want to know is... Is the class declared directly below the ngModule decorator only used to initialize a module or does…
12
votes
1 answer

Angular - Does importing unnecessary ngModules increase file size if they have been imported elsewhere?

I'm working with a rather large Angular application and currently have all shared components and modules inside a Shared Module which I import whenever I need anything which it exports. However I have some small feature-modules which only needs very…
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…
12
votes
3 answers

How to inherit a module from another module in Angular2?

So I'm using Angular 2 final (2.0.0) and let's say i create a WidgetsModule with a bunch of directives and components that will help me build my application, and then import it in my AppModule import { NgModule } from '@angular/core'; import {…
Pstr
  • 554
  • 4
  • 14
11
votes
1 answer

Angular2 : Dynamic component creation : AOT Compilation

Below is my initial code to create dynamic module: protected createComponentModule(componentType: any) { @NgModule({ imports: [ ComponentModule ], declarations: [ componentType ], }) …
10
votes
2 answers

Routing between Modules in Angular

I'm building simple angular application. There are two modules as student and teacher. Here is how my project organized. First when user enter to the application i let him to choose whether he is an teacher or student. Depending on what he user…
9
votes
2 answers

module declares component locally, but it is not exported

i have created a shared module and declared & exported the component i need in other modules. import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { DateslideComponent } from…
earlyBirdDev
  • 113
  • 1
  • 1
  • 5
9
votes
1 answer

Error : No Component Factory Found. Did you add it to @NgModule.entryComponents?

I am trying to create a popover on my Home Page.So I have created following function.. public presentPopover(myEvent) { let popover = this.popoverCtrl.create(TestComponent); popover.present({ ev: myEvent }); } in my…
CuriousAboutThings
  • 274
  • 2
  • 3
  • 12
8
votes
1 answer

Call platformBrowserDynamic().bootstrapModule(@NgModule) returns ASSERTION ERROR Type passed in is not NgModuleType, it does not have 'ɵmod' property

I have an issue with "platformBrowserDynamic().bootstrapModule(app.app_module)" call, the error message is "Uncaught Error: ASSERTION ERROR: Type passed in is not NgModuleType, it does not have 'ɵmod' property". However I can see this property…
Anatoli
  • 99
  • 1
  • 5
8
votes
1 answer

Angular2 - "Can't bind to 'ngSwitchWhen' since it isn't a known property of 'template'."

I am getting the following error "Can't bind to 'ngSwitchWhen' since it isn't a known property of 'template'." I've read different topics where it was advised to add import { CommonModule } from '@angular/common' and add "CommonModule" into the…
yhbv
  • 83
  • 1
  • 6
8
votes
2 answers

Does using Angular 2 router make sense in Ionic 2 application?

We have made an attempt at moving our Angular 2 app (written by a friend of ours, thus we might not know all the details) into Ionic 2. However, we haven't managed to make it work yet, thus questions below. Will Angular 2 router work in Ionic…
Ania
  • 317
  • 3
  • 12
1
2 3
12 13