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.

471 questions
13
votes
1 answer

Angular call function inside forRoot method

The problem is that I'm calling a function inside forRoot method like this: app.module.ts import {environment} from '../environments/environment'; ... @NgModule({ imports: [ BrowserModule, MyModule.forRoot({ config: { …
ismaestro
  • 5,270
  • 6
  • 31
  • 45
13
votes
2 answers

What does the app.module.ts file serve for, what should I do inside of it?

I'm getting used to Angular 2 but I have a few questions concerning the app.module.ts file. Why do I have to do the imports in this file since I will be doing the inputs again in the app.components.ts file. For example: I import my custom pipe…
masterach
  • 387
  • 1
  • 3
  • 16
12
votes
2 answers

Directive doesn't work in a sub module

I can't make the directive work in a lazy loaded module. I've read the documentation and I simply added the directive into declarations array of my main module. The directive works as expected at that module, but it doesn't work in lazy loaded…
omeralper
  • 8,325
  • 2
  • 16
  • 25
11
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…
devpato
  • 3,994
  • 6
  • 29
  • 67
11
votes
2 answers

Angular switch from lazyLoading to 'normal' loading

I am working on an Angular application that has lazy loading implemented. I tried experimenting with lazy loading but decided that I do not yet want to implement it in my application. This is my app.module.ts: app.module.ts: @NgModule({ …
hY8vVpf3tyR57Xib
  • 2,946
  • 4
  • 35
  • 73
11
votes
2 answers

Use component from AppModule in a child module in Angular X (X stands for 2+)

I have created a small component (LoadingComponent) in the root of my application and declared it (obviously) in my AppModule. This component is used when my application is loading and should show some fancy loading animations. Now I want to use it…
Florian Leitgeb
  • 12,686
  • 5
  • 27
  • 36
11
votes
1 answer

Loading modules from different server at runtime

Is it somehow possible to load different modules in my angular 2 app runtime, from different servers and if so, how can I achieve this? I would like to have my app load different components from the overall application from isolated servers (A, B,…
Myth1c
  • 619
  • 1
  • 7
  • 23
11
votes
2 answers

Utilizing Multiple Custom Modules in Angular 2 (RC5)

I have upgraded an ever-growing ng2 app to RC5 and have plopped all my components/pipes into one fat main module. To fight against the bloat, I was trying to carve my app into separate modules (also with an eye toward eventually doing lazy…
brando
  • 7,875
  • 7
  • 34
  • 54
10
votes
2 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.
10
votes
4 answers

"Please add a @NgModule annotation" Error on Angular2

I have made a custom angular2(5.0.x) module that looks like this : import { GuageService } from './services/guage.service'; import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { GuageComponent } from…
pxr_64
  • 451
  • 1
  • 8
  • 23
10
votes
1 answer

How to use directive that sits in a different module

angular.module('mod1', []) .directive('myDir', ($timeout) => { return { ///.... } }); angular.module('myApp', ['mod1']) So why this wouldn't work? and…
iLemming
  • 30,282
  • 53
  • 181
  • 302
9
votes
2 answers

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
  • 703
  • 7
  • 21
9
votes
1 answer

Angular/Typescript - Wildcard module declaration

I'm trying to implement wildcard modules and i don't seem to get it work: Right now i have the following code which works: typings.d.ts declare module "*.json" { const value: any; export default value; } app.component.ts import { Component,…
Luis Limas
  • 2,118
  • 18
  • 31
9
votes
1 answer

Angular package with NPM and GIT: dist folder in the repo?

What I want to achieve: I've created an Angular module and I want to npm install it from my GIT repo (I don't want to use npm publish, because it is a private code) in other projects. I'm using ng-packagr (https://github.com/dherges/ng-packagr) to…
Roland Rácz
  • 2,351
  • 2
  • 16
  • 36
9
votes
1 answer

Pack/Import a local developed module into a project

I am trying to import a locally developed Angular project/module into an angular application without publishing it into npm repository. First, I followed this tutorial to build my module in UMD format (I skipped the publish…
Strider
  • 2,717
  • 4
  • 20
  • 48
1
2
3
31 32