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
2
votes
1 answer

How to export const with NgModule

I have one constant which should be usable by other modules importing mine. I have Datepicker directive which has defined date formats constants (I have it like this so someone using my directive can use these constants): export const…
Slaven Tomac
  • 1,552
  • 2
  • 26
  • 38
2
votes
0 answers

Angular - Provide global service for lazyloading modules

So, I've 3 modules in my Angular app. // main module @NgModule({ declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } // lazy loading module @NgModule({ }) export class ClinicModule { } // lazy loading…
Jonathan
  • 39
  • 6
2
votes
0 answers

Convert a JavaScript import to an array?

I have a NPM package that I need to load most of the modules for. I can do the import statement like this: import * as primeng from 'primeng/primeng'; But in my @NgModule Angular declaration, I need to explicitly list out every single element in the…
John Fisher
  • 137
  • 3
  • 15
2
votes
1 answer

Angular 2 importing another "sibling" module injects the wrong Component

So I have a module structure like this: app ----pages ---------dashboard ---------posts Both dashboard and posts have their own routing. Here is how the routing looks like: Pages const routes: Routes = [ { path: '', component: Pages, …
Sumama Waheed
  • 3,579
  • 3
  • 18
  • 32
2
votes
2 answers

Angular 2 lazy-loading modules from within a lazy-loaded module

I'm developing a simple web page which has a Home Module wich contains two components, Homepage and Login which i load using Lazy-Loading... This is my App-Routing Module const routes: Routes = [ { path: '', redirectTo: 'home', pathMatch: 'full'…
BugsyFTW
  • 31
  • 1
  • 6
2
votes
0 answers

Angular 2 Universal lazy modules not working

So I first had my entire project working without Angular's universal (server-side rendering) and then I started off with the Angular Universal starter kit, and moved my project into the appropriate directories. Everything works now, except for any…
Gerardlamo
  • 1,505
  • 15
  • 21
1
vote
2 answers

Is it possible to inherit base class from shared module in Angular without explicit import

In my project there are many "base" component classes. Furthermore, the project is to be divided into several other modules, in which I simply wanted to use the share module as a base classes source. I hoped that it would be possible to use just one…
1
vote
0 answers

Removing unused import throws error in Angular 14

I am having a very weird issue. On the top section of imports, I have 2 declared imports that are not being used. More precisely, I have imported them, but did not declared them in the "imports" section of "NgModule". Now the weird issue starts…
1
vote
1 answer

Angular APP_INITIALIZER deps doesnt work - service is undefined

I am trying to use APP_INITIALIZER to do initial call for env values but for some reason service that have this function is undefined during runInitializers. Function is in our external library. I have tried to do this in library with the…
1
vote
1 answer

Configure a external Angular lib with .forRoot() that depends on a main Application service for populate config values

I have a custom Library that needs custom configuration within the forRoot() Library module, but I need to use an App Config Module that loads that configuration asynchronously instead of using static injected data as following. // Custom Library…
1
vote
1 answer

How to get a provided service from shared library in AppModule level? Angular

Im trying to create a Guard service to authenticate my routes. But my guard service are located in a shared library. This is my guard service: @Injectable({ providedIn: 'root' }) export class RouteGuard implements CanActivate { canActivate( …
Flávio Costa
  • 895
  • 5
  • 18
  • 41
1
vote
0 answers

Angular Module does not have 'ngModuelDef' property

Currently I am facing a strange Angular error. After a few minutes I am getting the following Error Message in my Browser Log: Type MyContainerModule does not have 'ngModuleDef' property. The project gets reloaded all the time. Sometimes I get also…
Elrond
  • 479
  • 1
  • 8
  • 21
1
vote
2 answers

Angular: where do I put services used by multiple modules

I just started using the feature module + lazily loaded routing part of angular framework, and have a bit of trouble getting used to the nuances. One thing that comes up now and again is how to store the services and interfaces- should they go in…
breadman0
  • 163
  • 1
  • 4
  • 14
1
vote
2 answers

Angular SVG Icon does not work with Angular Universal project lazy loading module

Angular: 11.2.5 Typescript: 4.0.2 Angular-svg-icon: 11.2.0 ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppHomeModule)[SvgIconRegistryService -> SvgIconRegistryService -> SvgLoader -> TransferState -> TransferState ->…
MD Ashik
  • 9,117
  • 10
  • 52
  • 59
1
vote
1 answer

NG0303: Can't bind to 'ngModel' since it isn't a known property of 'ion-range'

i'm started a few day ago with Ionic with angular project. I had a problem when i serve my project. this is the error: NG0303: Can't bind to 'ngModel' since it isn't a known property of 'ion-range'. I want to use the brightness puglin with…