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
1
vote
1 answer

Access Service variable in AppModule in Angular

I am implementing ngx-google-analytics in my Angular 10 app, but this module requires GA tracking code to be implemented this way: NgxGoogleAnalyticsModule.forRoot(environment.ga) Instead of environment variable or hardcoded code. I am looking to…
Jay
  • 524
  • 1
  • 7
  • 21
1
vote
0 answers

NgModule - How to receive a config and pass it to a nested, imported module in Angular?

I have a module (lets say module A) that imports another module (module B), that gets parameters though its forRoot. @NgModule({ declarations: [AComponent, XComponent], imports: [ BrowserModule, ModuleB.forRoot({ apiKey:…
Zephyer
  • 333
  • 6
  • 16
1
vote
1 answer

Angular modules - best practises of reusing shared components from domain modules with lazy loading

I know the concepts of lazy loading and sharing modules, but I'm not sure what will be the best practice of deviding code into modules in my app. I have 4 pages: Dashboard Drinks Drinks recipes Bars So I divided my app into 4 logical, domain…
SigGP
  • 716
  • 1
  • 11
  • 24
1
vote
0 answers

Why is component able to be access even if not in declaration of any module?

I have PageNotFoundComponent which I have not declared in any modules. Yet I have included it in a routing module to ensure that when we have no matching route this component will be in the router-outlet of app component. app.component.html …
1
vote
1 answer

Accessing angular library from angular app - StaticInjectorError in angular component with ElementRef in constructor

I created angular library (named ng-library) by following https://angular.io/guide/creating-libraries. Built it usin ng build ng-library Made it available to other angular applications using yarn link Created an angular application and linked the…
Bachu
  • 425
  • 4
  • 13
1
vote
2 answers

Angular - using forRoot({}) config in loadChildren() to configure a lazy-loaded module

I want to have a loaded module configurable. In theory, I want a module that is its own bigger application do receive some configuration. To show / load certain elements depending on the config the main application sends down. I used that with…
wenzel
  • 403
  • 4
  • 14
1
vote
1 answer

Why my Angular 7 app doesn't render anything in the root route when I setup lazy loading?

I have implemented lazy loading in my app and since then, the root route is not working. I have read some posts and apparently it doesn't work in Angular 7 with lazy loading, I should redirect from "" to "whatever". The point is that it doesn't do…
Gonzalo
  • 168
  • 1
  • 1
  • 7
1
vote
1 answer

Can we use System.import or import() function to any Javascript file or only Single module specific js?

Following a great article on dynamic component loading: https://blog.angularindepth.com/here-is-what-you-need-to-know-about-dynamic-components-in-angular-ac1e96167f9e I want to know more about the use of System.import. The author uses a following…
Deep
  • 929
  • 2
  • 16
  • 32
1
vote
0 answers

Totally flummoxed with "No NgModule Metadata found for..." issue with angular build

There's quite a few instances of this error out there on the web so I hope I'm not being too redundant. Alas, they all seem to end up with different issues needing to be resolved to fix it. At this time, I'm trying to narrow down where I should be…
DA.
  • 39,848
  • 49
  • 150
  • 213
1
vote
2 answers

Ionic: How to set a header on multiple pages?

I've created a new app using Ionic with 3 components, Home, Header and Footer. I'm trying to use Header and Footer on multiple pages (for now only on Home page), by making a reference to them. I've tried to reference the Header into the…
Cris
  • 13
  • 1
  • 3
1
vote
1 answer

What if I don't wrap my code in ngModules or services?

I'm currently beginning with Angular, previously having worked with React. So far, on other stacks, let's say I write a new file handle-error.js and selectively import it on a couple of pages, say endpoint1.js and endpoint2.js. Given that each of…
wkrueger
  • 1,281
  • 11
  • 21
1
vote
1 answer

Component is not part of any NgModule or the module has not been imported into your module (lazy loading)

I am working on Angular7 application and getting a strange error that my Component 'x' is not part of any NgModule or the module has not been imported into your module. Group Module: import { NgModule } from '@angular/core'; import { CommonModule }…
TAB
  • 1,944
  • 8
  • 28
  • 45
1
vote
1 answer

Should there be code in the constructor of an @NgModule and if so what are some reasons for it?

It is possible to do this and code gets run when the module gets loaded: import { NgModule } from '@angular /core'; @NgModule({...}) export class SomeNgModule { constructor(providedService: ProvidedService) { …
jonyeezs
  • 41
  • 1
  • 7
1
vote
1 answer

Entry components in Angular 5 lazy loaded module not working

I have developed an angular 5 application. I have divided my application into multiple modules like ReportModule, ProjectModule,etc. I am lazy loading these feature modules. { path: 'bulkrmchange', loadChildren:…
1
vote
1 answer

Angular 7 - Production Build Error - Cannot determine the module for class X Component! Add X Component to the NgModule to fix it

Checked similar issues, couldn't find answer A solution points to FileName error, but that don't seem to be the issue. Replaced it with a new component, still same error. Another solution points to case sensitive error, tried that, but did not…
Arun Prasad E S
  • 9,489
  • 8
  • 74
  • 87