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
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
  • 4,774
  • 2
  • 14
  • 30
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
  • 4,202
  • 9
  • 36
  • 65
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
  • 3,669
  • 5
  • 25
  • 42
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
  • 12,317
  • 20
  • 77
  • 124
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
  • 63
  • 5
3
votes
6 answers

Getting Error with HttpClient Module in angular

ERROR in node_modules/@angular/common/http/http.d.ts:81:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class. This likely means that the library (@angular/common/http) which declares…
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
  • 2
3
votes
1 answer

Angular aot build: dynamic forRoot parameter results in undefined

I need to send a configuration (array of objects) to a service in a feature module and this configuration needs to be dynamically calculated. I used forRoot and it worked fine until I've built it with --aot. problem: With --aot, the configuration…
stanus
  • 31
  • 3
3
votes
0 answers

Angular shared package: Unexpected value '' imported by the module 'AppModule'. Please add a @NgModule annotation

I'm developing a new Angular (cli-based) application. In anticipation of future projects, I'm attempting to split out common domain-specific services into a shared package NgModule into a second app which is a filesystem peer to my main app, like…
Stuart Updegrave
  • 667
  • 5
  • 23
3
votes
1 answer

Load Angular 2 Module only when a condition is met

In my angular (v.4.1.1) applications, I am using drag-and-drop functionality. Basically, everything between tags can be moved around via drag-and-drop. Animations and preview items work fine in newer Browsers such as Chrome and Edge but in Internet…
David Brem
  • 365
  • 2
  • 3
  • 14
3
votes
1 answer

Providers Array in app.module.ts in Angular 2

This might just well be a trivial question but I need to clarify the doubts. I was following the tutorial https://angular.io/docs/ts/latest/tutorial/toh-pt5.html and suddenly it stuck me. In my hero.component.js I have import { Component } from…
StrugglingCoder
  • 4,231
  • 11
  • 55
  • 90
3
votes
1 answer

How to make a angular2 module (ngModule) configurable

Assuming that we have a module which does some authentication stuff in it. I want to set some variables while adding the module to the project. I've seen that the routing module does something similar with the function forRoot(routes). So I tried…
eav
  • 1,925
  • 7
  • 24
  • 34
3
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
  • 84
  • 7
3
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
  • 311
  • 1
  • 2
  • 12
3
votes
1 answer

ngModule import module for entire app?

I'm upgrading my app to angular2 RC and I have a question about ngModule. Lets say I use some componentsModule that has all kind of components that I want to use around my app. Why would I need to import them in every module separately? Why cant I…
David Limkys
  • 4,157
  • 4
  • 21
  • 36
1 2
3
12 13