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
8
votes
3 answers

Angular: one module for every component: antipattern?

So I have encountered a practice where people will create a module for each component that has service dependencies. that way, when someone wants to use a given component, they dont have to read through the code to see what providers to add to the…
squirrelsareduck
  • 874
  • 1
  • 10
  • 15
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
  • 327
  • 3
  • 12
8
votes
2 answers

Angular 2 - Unexpected Module declared by AppModule

I am new to angular and trying to separate my modules in Angular2 app having the following directory structure. I have my module and other components declared in the AppModule, but I am getting an error in browser console that Unexpected HomeModule…
mdanishs
  • 1,996
  • 8
  • 24
  • 50
8
votes
1 answer

Add Models/Entities/Objects to NgModule in Angular 2

I've been trying to create an @NgModule (named ModelsModule) made of objects like User, Book, Library, Movie, and so on. Doing this I'm trying to not to import every object every time I need it but importing them at the beginning in the AppModule…
cbelda
  • 83
  • 1
  • 5
7
votes
2 answers

Angular - Should HttpClientModule be in the Exports array in the CoreModule?

Well, I'm structuring my project following the infrastructure of: Feature module. Core module. Shared module. But there's something that I still don't have clear enough. As far as I know, the HttpClientModule should be in the CoreModule because…
RottenCheese
  • 869
  • 2
  • 12
  • 18
6
votes
0 answers

Angular 6 - Custom pipes in shared module not being exported

My Angular architecture is composed of 3 modules. AppModule (where the app prensetation and logic resides) CoreModule (Contains my services to access API) SharedModule (Contains my models, pipes, directives, etc...) I want to add a new pipe in my…
Eastrall
  • 7,609
  • 1
  • 16
  • 30
6
votes
5 answers

Component cannot be used as an entry component

import { SpinnerComponent, ExternalLibrary } from 'external.library' @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, ExternalLibrary ], bootstrap: [AppComponent] , entryComponents:…
Ashutosh Singh
  • 609
  • 6
  • 21
5
votes
0 answers

Lazy loaded modules are being bundled with main chunk

I have a client's project that is using the Angular 6 framework. There are several modules in the project, 16 of which are supposed to be lazy-loaded (e.g. loadChildren). But when I run build for production, only 9 of those modules have their own…
shihab
  • 51
  • 2
5
votes
0 answers

How to do injection in Angular Module imports

I'm importing a configurable module from an external library like this: @NgModule({ imports: [ThirdPartyModule.forRoot(MY_CONFIG)] }) Problem is that MY_CONFIG is not static and makes use of a service in order to define its value, so I would use…
Thiezar
  • 1,143
  • 2
  • 10
  • 16
5
votes
2 answers

Import a service from another module

I am currently learning the Angular framework (version 5) after developing 2 years with the AngularJS 1.x framework, so I ask myself a lot of questions and one of them is the way to properly import a service provided by another module that the one…
Alexandre D.
  • 711
  • 1
  • 9
  • 28
5
votes
2 answers

No provider for XHRBackend with Angular 2 and Http service

I'm building a project based on angular2 (angularcli generated), webpack, scss, and module oriented. For http request I decided to create a Service that is used by an Authentication service. All referenced in a CoreModule import {NgModule} from…
An-droid
  • 6,433
  • 9
  • 48
  • 93
5
votes
3 answers

How can i export a class to module and import the same in another module in typescript with angular

I have a class(IGeneric) which is exported to the module A and I imported that Module(A) in module B, but I could not use that exported class(IGeneric) in the module B. Note : that exported class is not a component,directive and service.it is a…
praveen
  • 228
  • 1
  • 2
  • 10
4
votes
0 answers

Angular 6 multiple routing outlets with child routing

I have app module which imports two child modules: PreparationModule and GameModule. In root routing for AppModule i have 'preparation' endpoint which lazy loads PreparationModule. AppComponent's (bootstrap component for AppModule) html file…
kubi
  • 897
  • 2
  • 9
  • 23
4
votes
1 answer

Must I reimport modules and styles in lazy loaded modules?

In Angular 2+ I’m lazy loading a custom module (section of my app). It lazy loads just fine when i navigate to its route, but it has none of my main module’s theming. Also I’ve found that I have to re-import MatButtonModule in my custom module if I…
seabass
  • 1,030
  • 10
  • 22
4
votes
0 answers

Understanding Angular module scope (for ngx-bootstrap)

I'm kinda new to Angular and am having issues integrating ngx-bootstrap in my project when using ng modules... To be more brief - Everything works properly when I add html directly in app.component.html but won't work when I add the same code in…
1
2
3
14 15