Questions tagged [angular-module]

You can think of an Angular/AngularJS module as a container for the different parts of your app – controllers, services, filters, directives, etc.

Most applications have a main method that instantiates and wires together the different parts of the application.

Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach:

  • The declarative process is easier to understand.
  • You can package code as reusable modules.
  • The modules can be loaded in any order (or even in parallel) because modules delay execution.
  • Unit tests only have load relevant modules, which keeps them fast.
  • End-to-end tests can use modules to override configuration.

Full documentation on AngularJS modules.

555 questions
517
votes
6 answers

What is the difference between declarations, providers, and import in NgModule?

I am trying to understand Angular (sometimes called Angular2+), then I came across @Module: Imports Declarations Providers Following Angular Quick Start
Ramesh Papaganti
  • 7,311
  • 3
  • 31
  • 36
309
votes
7 answers

Use component from another module

I have Angular 2.0.0 app generated with angular-cli. When I create a component and add it to AppModule's declarations array it's all good, it works. I decided to separate the components, so I created a TaskModule and a component TaskCard. Now I…
Evgeni Dimitrov
  • 21,976
  • 33
  • 120
  • 145
229
votes
23 answers

Angular 2 'component' is not a known element

I'm trying to use a component I created inside the AppModule in other modules. I get the following error though: "Uncaught (in promise): Error: Template parse errors: 'contacts-box' is not a known element: If 'contacts-box' is an Angular…
Aranha
  • 2,903
  • 3
  • 14
  • 29
164
votes
7 answers

What is entryComponents in angular ngModule?

I am working on an Ionic app ( 2.0.0-rc0 ) which depends on angular 2 . So the new introduction of ngModules is included. I am adding my app.module.ts. below. import { NgModule } from '@angular/core'; import { IonicApp, IonicModule } from…
raj
  • 5,989
  • 7
  • 30
  • 62
105
votes
5 answers

How to declare a pipe globally to use in different modules?

I have a custom pipe named CurrConvertPipe import {Pipe, PipeTransform} from '@angular/core'; import {LocalStorageService} from './local-storage'; @Pipe({name: 'currConvert', pure: false}) export class CurrConvertPipe implements PipeTransform { …
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
86
votes
3 answers

No Provider for CustomPipe - angular 4

I've a custom decimal format pipe that uses angular Decimal pipe inturn. This pipe is a part of the shared module. I'm use this in feature module and getting no provider error when running the application. Please ignore if there are any…
mperle
  • 3,342
  • 8
  • 20
  • 34
64
votes
2 answers

Role of imports / exports in Angular 2+ ngModule

I'm learning Angular 2+ and I'm having a hard time understanding the role of imports/exports in an ngModule. More specifically why is important to import a module if you're going to import it anyway using es6 syntax as well import { BrowserModule }…
Doua Beri
  • 10,612
  • 18
  • 89
  • 138
34
votes
1 answer

When to use Standalone Components or Modules in Angular 14?

I would like to know when should I use Standalone components and when should I create a new module. Since it's a new concept introduced in Angular, what are the criteria to use them? I've created a new whole app only using standalone components with…
ismaestro
  • 7,561
  • 8
  • 37
  • 50
29
votes
5 answers

How to import all Angular Material modules in Angular 9

I want to import all angular material modules and use into overall angular project templates.
25
votes
3 answers

Angular - Using a component across multiple modules

What I'm using Angular What I'm trying to do I have a loading component I want to reuse across multiple modules What I've done I've created a new module called 'loading-overlay' Inside this module I export the overlay component I add this…
MegaTron
  • 3,133
  • 6
  • 28
  • 45
25
votes
5 answers

Angular router: how to pass data to lazy loading module?

I have the following routing paths for a module of my Angular app: @NgModule({ imports: [ RouterModule.forChild([ { path: 'documents', data: { myObject: MyConstants.OPTION_ONE }, …
smartmouse
  • 13,912
  • 34
  • 100
  • 166
23
votes
2 answers

Angular Service singleton constructor called multiple times

I am trying to use an app-wide service (UserService) that stores authenticated user details. I have set up some routes but found that UserService is instantiated per route. I want them to share the same UserService. I have created a CoreModule…
22
votes
1 answer

NullInjectorError: No provider for DecimalPipe

I have implemented lazy loading in my application. One of my services needs to include DecimalPipe. service --> shared module --> App module This is my structure. I've already included "CommonModule" in app.module.ts and My service also needs…
Ravi
  • 881
  • 1
  • 9
  • 23
20
votes
3 answers

Module has no exported member error in angular module

I wanted to create a feature module which will handle the front end for an upload. upload.component.html No errors.
20
votes
2 answers

Load ngModule and its components based on conditional in Angular

I'm new in angular and I was wondering if it's possible to load and module and its components I made based on a conditional on the app.module or where would it be the best place to do this. Basically I want to do something like: if(user.deparment…
Patricio Vargas
  • 5,236
  • 11
  • 49
  • 100
1
2 3
36 37