Questions tagged [angular2-modules]

132 questions
83
votes
7 answers

error TS1192: Module '" A.module"' has no default export

I have created a new module 'A' and trying to import it in another module called 'B'. I am getting this error on compiling that says error TS1192: Module '" A.module"' has no default export Can anyone please help on how to solve this error.
Abhi
  • 3,387
  • 3
  • 12
  • 19
72
votes
10 answers

Lazy Loading BrowserModule has already been loaded

I am trying to implement lazy loading but getting error as following ** ERROR Error: Uncaught (in promise): Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module,…
69
votes
7 answers

How to route to a Module as a child of a Module - Angular 2 RC 5

I am in the process upgrading an application I'm working on to the latest Angular 2 release candidate. As part of this work I am attempting to use the NgModule spec and migrating all of the parts of my application to modules. For the most part, this…
47
votes
10 answers

Angular2 module has no exported member

For a website with authentication in Angular2, I want to use a component of the authentication submodule in the main app component. However, I keep getting the following error: app/app.component.ts(3,10): error TS2305: Module…
user2416984
  • 857
  • 1
  • 9
  • 16
45
votes
7 answers

How to share service between two modules - @NgModule in angular not between to components?

In my application, I have two different bootstrap module (@NgModule) running independently in one application. There are not one angular app bit separate bootstrap module and now I want they should communicate to each other and share data. I know…
Aniruddha Das
  • 14,517
  • 13
  • 83
  • 111
40
votes
2 answers

How to declare a directive globally for all modules?

I'm developing a Github repo which follows the offical tutorial of Angular (Tour of Heroes). You can see all the code here. My problem, is that I have a directive declared in the main module of the app (app.module) and, if I use it inside the…
ismaestro
  • 5,270
  • 6
  • 31
  • 45
35
votes
4 answers

Angular2 router: how to correctly load children modules with their own routing rules

here is my Angular2 app structure: Here is part of my code. The following is the main module of the Angular2 app, that imports its routing rules and a child module (EdgeModule) and uses some components related to some…
27
votes
3 answers

Unexpected value 'MyCustomModule' imported by the module 'AppModule'

I am trying to migrate one of my angular2 custom library to RC.6 + Webpack. My directory structure is: - src - source TS files - lib - transpiled JS files + definition files - dev - development app to test if it works / looks ok. - myCustomLib.js -…
Baumi
  • 1,647
  • 1
  • 15
  • 28
26
votes
1 answer

Angular2 - 'Can't resolve all parameters' error while injecting http into a custom service

I have built an ErrorHandlerLogger which is a service which extends ErrorHandler and logs error messages into a remote repository. ErrorHandlerLogger requires the Angular http client provided by the HttpModule. In the ErrorHandlerModule I import…
Picci
  • 12,727
  • 9
  • 48
  • 85
25
votes
2 answers

Angular2 Module: How can i import a service from another module

import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { ClinicFacilityService } from './apiClient.module'; @NgModule({ imports: [ CommonModule, …
Kimaina Allan
  • 317
  • 1
  • 4
  • 11
24
votes
5 answers

Angular: Lazy loading modules with services

I've been following this tutorial, to understand lazy loading, and below is my inference. Scenario 1: Services are provided by putting them in the providers array of a child module Scenario 2: Services are provided in a child module using the…
23
votes
1 answer

Angular 2 difference between core and feature modules

I don't understand the difference between core and feature modules in angular 2. As far as I understand there are three recommended types of modules: core, feature and shared. If a module exports some declarations (components, directives and pipes)…
Ildar
  • 3,111
  • 3
  • 35
  • 66
18
votes
5 answers

Angular 2: Module not found: Error: Can't resolve

I have a simple app created with Angular-CLI, I wanted to refactor and move the app.component.ts code in separate component file and started to get a nasty error: Module not found: Error: Can't resolve on './sb/sb.component.html' ( my…
joeCarpenter
  • 1,255
  • 4
  • 17
  • 25
16
votes
2 answers

Inherit imports from parent module to child module in Angular2

I made an Angular2 app like described here. It has two components (A,B) which are imported by the global app.module. My idea was, to include shared modules in app.module, so I don't need to mess up every module with redundant code. I want to do that…
Lion
  • 11,498
  • 13
  • 55
  • 113
16
votes
2 answers

Angular 2 define data models for multiple modules

I'm currently starting a new project with Angular 2.0 (release Version) and I want to define some global data models/schemas. As I understand it, Angular 2 has no default way of handling pure data classes like this: export class TestModel { id:…
1
2 3
8 9