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

Trying to lazy load Angular Material related custom module for lazy loaded components using forRoot() doesn't work

I have a lazyloading modules setup through angular-routing , i am using angular-material package for rendering data. As recommended i have made a custom module for materail-components named MaterialModule (with a forRoot method) I import it in…
1
vote
1 answer

Why adding a Material Module breaks the dynamic component insertion?

Here are two MCVEs on StackBlitz using dynamic component creation. I would like to understand why : This works. But this does not work, just after importing a Material Module (MatButtonModule) into the dynamically created module. Does anyone have…
Hadrien TOMA
  • 2,375
  • 2
  • 22
  • 32
1
vote
2 answers

Angular pass a component from a module to another module in the App module

I have an issue figuring out how I can pass a component from a module I import into my Angular application and use it inside another module that I import also in my App. Note that all those two modules are modules I created. That's my app.module.ts…
Imad El Hitti
  • 917
  • 3
  • 10
  • 23
1
vote
0 answers

Angular Library Module pass configuration to be used in NgModule decorator

I created an Authentication Angular Library project to abstract the provider I'm using. Since angular library projects do not support environment configuration, I'm looking for a way for the consuming application project to be able to pass the…
Jake Smith
  • 2,332
  • 1
  • 30
  • 68
1
vote
1 answer

ngmodule Module parse error with unexpected character '@'

I've gone through the tutorial on https://angular.io/tutorial/toh-pt0, and I'm currently trying to compile the tutorial into a /public/ folder and getting the error... Module parse failed: Unexpected character '@' You may need an …
1
vote
0 answers

Unable to change or give custom CSS for ng-datepicker

I am trying to give custom CSS for bs-datepicker. But, its not accepting any change from component.css. I tried adding a class name in the node file of bs-datepicker in node_modules and making css changes using that class name, but the changes are…
BlizZard
  • 587
  • 5
  • 22
1
vote
1 answer

How to access a SharedService at Module level in Angular 5+

I'm relatively new to Angular5/TypeScript, so I apologize for the (maybe) trivial question. I'm trying to implement an authentication service which I intend to use in order to let my Angular5 frontend, consume some REST API exposed by a wordpress…
user4096537
1
vote
1 answer

What is that metadata object which @NgModule decorator takes in Angular?

I was studying about Ngmodule from the official website of the Angular. There, it is written the following statement: @NgModule takes a metadata object that tells Angular how to compile and launch the application. I searched on many pages but I am…
KhiladiBhaiyya
  • 633
  • 1
  • 14
  • 43
1
vote
0 answers

With angular 5 and webpack, for 'production' build I see 'Please add a @NgModule annotation.' for the first imported module

I have a large project that was working well under webpack, angular 4 and recently moved to angular 5, and an improved webpack config. The 'development' build loads just fine. But the 'production' build loads and dies with a 'Please add a @NgModule…
JoelParke
  • 2,676
  • 2
  • 24
  • 38
1
vote
3 answers

Angular 2 component doesnt render even if i put it in NgModule

I have a problem with rendering custom component. Even if i put my shared module in NgModule it doesnt render. I get an error where it says that i should add component to NgModule or add property schemas with parameter CUSTOM_ELEMENTS_SCHEMA. As i…
A. Omahen
  • 11
  • 2
1
vote
0 answers

Unable to open ModalController with lazy loading ionic3

I'm implementing lazy loading in my ionic 3/angular5 app in order to boost performance. But I'm unable to open a modal using it and it drives me crazy. I have a page (Journal in red) where I load messages and display them (message-item in green).…
Jibeee
  • 822
  • 1
  • 11
  • 26
1
vote
1 answer

Angular2: what is the best practice to decompose into module(s) a feature that contains both a directive and a service?

I am planning to develop a feature in Angular2 to contribute to the community. The feature consists of one directive and one service. I am wondering how I can best pack the feature into one module (or more modules). The service must be global, so…
1
vote
1 answer

What does empty .forRoot() exactly do in angular2?

I've seen people using .forRoot() in their projects along with the main forRoot(paths inside...) which brings them to the sub-url. What is the purpose of this empty for root? Example (it is used in the imports of the defined Module): …
masterach
  • 437
  • 1
  • 6
  • 19
1
vote
1 answer

How to access DirectivesModule from a component which uses some of the directive inside?

Edited: The proposed solution is the right one, I had to mention that SharedModule has to be imported into the parent component of the child component which uses DropDownDirective in order to work. I'm working on Angular 4 application and I wanted…
Petya Naumova
  • 727
  • 2
  • 11
  • 23
1
vote
0 answers

Calling Module of another Angular app in you angular app

Is it possible that i can lazy load a module attached to another angular app in the calling angular app? Say i have Angular App A1 and A2 I want A1 as main angular app served to client. Now i want to add a new module folder to A2 ,build it and keep…
Ankit Raonka
  • 6,429
  • 10
  • 35
  • 54