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

Passing input data into a lazy-loaded Angular module

I have a component called NewsComponent which is shared within my app. I would like to expand it into a NewsModule and add a routing system to display individual articles, so that my routes would look…
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
  • 4
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
  • 687
  • 5
  • 25
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
  • 504
  • 2
  • 6
  • 16
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,781
  • 16
  • 69
  • 103
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
  • 2,123
  • 7
  • 25
  • 34
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,907
  • 5
  • 26
  • 38
2
votes
0 answers

What are the advantage of writing angular app using standalone components

I have seen many docs regarding standalone components creation and its usage. But i havent found any doc stating the advantages of standalone components implementation against ngmodules approach. We can get rid of too many module s creation and…
bvakiti
  • 3,243
  • 4
  • 17
  • 26
2
votes
2 answers

How to access a reusable component from one another reusable component and a container component

In our Angular 8 project, we have a container component for user registration (user.registartion). Also, we have a reusable component for updating the user information (user.component). Both components has to show a 'user policy' pop-up which is…
Vignesh VS
  • 921
  • 1
  • 14
  • 30
2
votes
3 answers

ngFor is not working despite having CommonModule imported in the existing module

ngFor is not working in my code. I have the following code structure. AppModule - contains App Component with router-outlet HomeModule - contains Home Component - uses ngFor. (ngFor works here with no issues) TestModule - contains Test Module -…
shazim
  • 21
  • 4
2
votes
1 answer

Angular: Can`t resolve all parameters for Component

I have downloaded a simple Angular app from this demo. After using npm i and ng serve I keep getting this message. Been trying to fix it, figured i will get some help here, since i have not found any solution elsewhere. Same thing happens to every…
DerzkeyBK
  • 165
  • 1
  • 9
2
votes
2 answers

How to use relative angular component in Storybook?

Consider this structure; --MyModule ----Header ----HeaderLogo I'm trying to develop angular components in storybook. I am able to see and develop a single component, but when I import component into another component (header logo into header) (same…
Mohamed
  • 71
  • 3
  • 7
2
votes
1 answer

ng build --prod dynamic variables get lost

i have a ngModule which uses ngx-socket-io, i removed the unnecessary imports and injections :) as you can see i have commented some code which works like charm only in development build of application, as soon as i build the app using --prod those…
Navid Kianfar
  • 171
  • 1
  • 10
2
votes
0 answers

Passing environment variables to custom library with forRoot()

I am trying to pass environment specific variables to my own library. And I'm passing it through forRoot(). For hard-coded values i am able to pass it but for environment values when i pass it to the library, it shows as undefined. const rootUrl =…
2
votes
1 answer

Angular 5 Static Injector error when injecting a component from a sharedmodule

Here is my component file. I am trying to create a reusable modal component using ng-bootstraps modal. I am getting a static injector error when I try to import the following component from the shared module. I have looked at many other resources…
CLR45
  • 185
  • 1
  • 16