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

218 questions
4
votes
3 answers

Angular 4 are services provided in a core module singleton for real?

I'm trying to understand core module and singleton services in angular 4. The official documentation (https://angular.io/guide/ngmodule) says the following things: UserService is an application-wide singleton. You don't want each module to have…
user2010955
  • 3,871
  • 7
  • 34
  • 53
4
votes
0 answers

ERROR in Unexpected value 'DataTableModule imported by the module 'AppModule

i have an error when i run ng build -prod in my angular 4 application it said "ERROR in Unexpected value 'DataTableModule in Y:/example/node_modules/angular-2-data-table/dist/index.d.ts imported by the module 'AppModule. Please add a @NgModule…
Sandy
  • 210
  • 3
  • 16
4
votes
2 answers

Why is it must to import SharedModule to Root Module?

Angular 2 document states "Shared features modules must be imported by any module expecting to use it's declarables". I wonder why is it must to import Shared features module in to root module. Does it increase code base complexity?
Albert
  • 94
  • 7
4
votes
0 answers

Angular2: Get access to entryComponents property of Module inside a Component

In my Angular2 module I've specified an array of components in the entryComponents property like this: @NgModule({ // ... entryComponents: [ComponentA, ComponentB] // ... }) export class AppModule { } In a component I want to access…
Zteve
  • 341
  • 1
  • 2
  • 12
4
votes
1 answer

Angular 2 final version - ngModule does not recognize shared component

I am having problems with the configuration for ngModule and my components, running final released version of Angular 2. this is what I have: //PageHeaderModule import { NgModule } from '@angular/core'; import { CommonModule } from…
Alejandro Lora
  • 7,203
  • 3
  • 18
  • 34
4
votes
2 answers

One single NgModule versus multiples ones with Angular 2

I'm wondering if it's better to create one single module that contains all my angular 2 code or if it is better to split everything across multiple modules. For example, I'm creating my blog with Angular 2. So I have a "article-list" component and…
ssougnez
  • 5,315
  • 11
  • 46
  • 79
4
votes
1 answer

Understanding @NgModule usage

This new @NgModule crap has got me stumped. Before, I was able to cleanly specify a @Component's directive dependencies via the directives: [] attribute of the @Component meta object. So: @Component({ /* ... */ }) export class Cmp1 {} @Component({…
AndyPerlitch
  • 4,539
  • 5
  • 28
  • 43
4
votes
2 answers

how to use sharedModule in angular2?

I have one angular2 component which I want to share among multiple modules. So I wrote below sharedModule , import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import {GenericComponent} from…
Bhushan Gadekar
  • 13,485
  • 21
  • 82
  • 131
3
votes
1 answer

Cannot determine the module for class Component in component.ts file, add component to the NgModule to fix it

I have a project which uses angular libraries. So for the development of the library, I am using the build command with the watch option, so when I make a change to the library code, it will be automatically compiled and built. Then on another tab…
Happy Coder
  • 4,255
  • 13
  • 75
  • 152
3
votes
3 answers

Can't bind to ngModel since it isn't a known property of input error

I have imported FormsModule in the module.ts but still compilation is failing with error - can't bind to 'ngModel' since it isn't a known property of input. Note: I encountered the error after I created separate modules for each of the component in…
Pri645
  • 85
  • 1
  • 2
  • 10
3
votes
2 answers

Cannot declare 'TimeAgoPipe' in an NgModule as it's not a part of the current compilation

I am getting an error in Angular 10 while doing ng build --prod. It works in ng build. ERROR in src/app/app.module.ts:44:5 - error NG6001: Cannot declare 'TimeAgoPipe' in an NgModule as it's not a part of the current compilation. 44 …
R15
  • 13,982
  • 14
  • 97
  • 173
3
votes
0 answers

Migration Angular 8 to 9 (Symbol is not exported)

After my angular app migration from 8.2 to angular 9 I'm facing the following error: ERROR in Symbol XptoComponent declared in C:/path/xpto.component.ts is not exported from @angular/core (import into C:/path/parts.module.ts). The code…
JMarques
  • 3,044
  • 4
  • 34
  • 55
3
votes
1 answer

Angular 10 No provider for ModalDialogService

recently I upgrated Angular 8 to Angular 10 and as it turns out I got one error which is: NullInjectorError: No provider for ModalDialogService! NullInjectorError: R3InjectorError(AppModule)[ModalDialogService -> ModalDialogService ->…
Krzysztof
  • 152
  • 1
  • 2
  • 15
3
votes
0 answers

TSLint: imports of lazy loaded libraries are forbidden: Downgraded Component, Module imported at AppModule and in angular bootstrap

I have a mixed (Angular JS, Angular 8) application where all routing is done at Angular JS. Let's assume, libs |--- XYZLibrary/src |--- index.ts // Exports XYZModule and DetailComponent |--- lib |--- MainComponent // Component …
adtgoel
  • 31
  • 3
3
votes
1 answer

Potential drawbacks of Angular module importing modules it doesn't use?

Let's say that in my Angular app I have an NgModule, and I would like to add a bunch of modules to its imports array. I don't want to import each module individually, but instead gather modules in a group and import the entire group instead. Some of…
Alice
  • 585
  • 5
  • 16
1 2
3
14 15