ng-modules

How to inherit a module from another module in Angular2?

狂风中的少年 提交于 2019-12-06 19:16:40
问题 So I'm using Angular 2 final (2.0.0) and let's say i create a WidgetsModule with a bunch of directives and components that will help me build my application, and then import it in my AppModule import { NgModule } from '@angular/core'; import { UniversalModule } from 'angular2-universal'; import { WidgetsModule } from '../../../widgets'; import { App, appRouting } from './'; @NgModule({ imports: [ UniversalModule, WidgetsModule, appRouting ], providers: [ AppPresenter ], declarations: [ App ],

No provider for XHRBackend with Angular 2 and Http service

半世苍凉 提交于 2019-12-06 03:19:23
问题 I'm building a project based on angular2 (angularcli generated), webpack, scss, and module oriented. For http request I decided to create a Service that is used by an Authentication service. All referenced in a CoreModule import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {RequestOptions, XHRBackend} from '@angular/http'; // Services import {HttpService} from './services/http.service'; import {AuthService} from './services/auth/auth.service'; export

Angular2 - “Can't bind to 'ngSwitchWhen' since it isn't a known property of 'template'.”

試著忘記壹切 提交于 2019-12-05 10:59:37
I am getting the following error "Can't bind to 'ngSwitchWhen' since it isn't a known property of 'template'." I've read different topics where it was advised to add import { CommonModule } from '@angular/common' and add "CommonModule" into the imports section of @NgModel, which I did, however this did not solve the problem. I can't figure out what I'm doing wrong, any help in how to fix this? This is my code for "app.component.ts" import { Component } from '@angular/core' @Component({ selector: 'app-root', template: ` <ul class="nav nav-pills"> <li [class.active]="viewMode == 'map'"><a (click

How to inherit a module from another module in Angular2?

柔情痞子 提交于 2019-12-05 00:41:45
So I'm using Angular 2 final (2.0.0) and let's say i create a WidgetsModule with a bunch of directives and components that will help me build my application, and then import it in my AppModule import { NgModule } from '@angular/core'; import { UniversalModule } from 'angular2-universal'; import { WidgetsModule } from '../../../widgets'; import { App, appRouting } from './'; @NgModule({ imports: [ UniversalModule, WidgetsModule, appRouting ], providers: [ AppPresenter ], declarations: [ App ], exports: [ ], bootstrap: [ App ] }) export class AppModule { } Then i want to use widgets in the child

No provider for XHRBackend with Angular 2 and Http service

元气小坏坏 提交于 2019-12-04 08:54:38
I'm building a project based on angular2 (angularcli generated), webpack, scss, and module oriented. For http request I decided to create a Service that is used by an Authentication service. All referenced in a CoreModule import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {RequestOptions, XHRBackend} from '@angular/http'; // Services import {HttpService} from './services/http.service'; import {AuthService} from './services/auth/auth.service'; export function httpInterceptor(backend: XHRBackend, defaultOptions: RequestOptions) { return new HttpService

How to correctly import FormGroup in NgModule in Angular 2

有些话、适合烂在心里 提交于 2019-12-03 10:07:12
I try to import FromGroup , FormBuilder and FormControl to my CustomModule : import { FormsModule, FormGroup } from '@angular/forms'; @NgModule({ imports: [ FormsModule, FormGroup ] }) But it throws an error: EXCEPTION: Uncaught (in promise): Error: Unexpected value 'FormGroup' imported by the module 'CustomModule' If i only import FormsModule it works fine though. Any ideas? You can't add FormGroup to module's imports, just import it in the component in which you want to use FormGroup . You can only add MODULES to module's imports . Also, if you want to use FormGroup directive, you will need

Many Modules using the same component causes error - Angular 2

你说的曾经没有我的故事 提交于 2019-12-03 08:45:51
问题 I have a shared component called GoComponent that I want to use in 2 modules: FindPageModule and AddPageModule. When I add it in the declarations of "FindPageModule" and in my "AddPageModule" I get an error: find:21 Error: (SystemJS) Type GoComponent is part of the declarations of 2 modules: FindPageModule and AddPageModule! Please consider moving GoComponent to a higher module that imports FindPageModule and AddPageModule. You can also create a new NgModule that exports and includes

Many Modules using the same component causes error - Angular 2

梦想与她 提交于 2019-12-02 22:38:52
I have a shared component called GoComponent that I want to use in 2 modules: FindPageModule and AddPageModule. When I add it in the declarations of "FindPageModule" and in my "AddPageModule" I get an error: find:21 Error: (SystemJS) Type GoComponent is part of the declarations of 2 modules: FindPageModule and AddPageModule! Please consider moving GoComponent to a higher module that imports FindPageModule and AddPageModule. You can also create a new NgModule that exports and includes GoComponent then import that NgModule in FindPageModule and AddPageModule. So I take it out of them both and

Angular 4 are services provided in a core module singleton for real?

余生长醉 提交于 2019-11-30 23:14:57
I'm trying to understand core module and singleton services in angular 4. The official documentation ( https://angular.io/guide/ngmodule ) says the following things: UserService is an application-wide singleton. You don't want each module to have its own separate instance. Yet there is a real danger of that happening if the SharedModule provides the UserService. CoreModule provides the UserService. Angular registers that provider with the app root injector, making a singleton instance of the UserService available to any component that needs it, whether that component is eagerly or lazily

Angular 4 are services provided in a core module singleton for real?

此生再无相见时 提交于 2019-11-30 18:03:49
问题 I'm trying to understand core module and singleton services in angular 4. The official documentation (https://angular.io/guide/ngmodule) says the following things: UserService is an application-wide singleton. You don't want each module to have its own separate instance. Yet there is a real danger of that happening if the SharedModule provides the UserService. CoreModule provides the UserService. Angular registers that provider with the app root injector, making a singleton instance of the