thisプロジェクトから派生した角度4のプロジェクトでthisライブラリを使用しようとしています。このライブラリのモジュールをコンポーネントモジュールにインポートするとうまく動作します。複数の角度コンポーネントで第三者指令を共有する
import { NgModule, } from '@angular/core';
import { LoadingModule } from 'ngx-loading';
import { Login } from './login.component';
@NgModule({
imports: [
LoadingModule,
],
declarations: [
Login
]
})
export class LoginModule { }
上完全に正常に動作します:たとえば、私はlogin.module.tsを持つログインコンポーネントを持っています。
ただし、重複したコードを作成するため、すべてのコンポーネントでこのモジュールをインポートする必要はありません。したがって、共有モジュールを作成し、その共有モジュールをログインコンポーネントのモジュールとレジスタコンポーネントのモジュールにインポートしました。
このような何か:
import { NgModule } from '@angular/core';
import { LoadingModule } from 'ngx-loading';
@NgModule({
imports: [
LoadingModule,
],
})
export class SharedModules {
}
はlogin.moduleでこれをインポートしようとしました:
import { SharedModules } from '../../sharables/shared.module';
@NgModule({
imports: [
SharedModules,
],
declarations: [
Login
]
})
export class LoginModule { }
また、私は私のメインapp.moduleでSharedModulesを輸入しています。
Can't bind to 'show' since it isn't a known property of 'ngx-loading'.
1. If 'ngx-loading' is an Angular component and it has 'show' input, then verify that it is part of this module.
2. If 'ngx-loading' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
- どのように私は角4でこれを達成することができます:上記
次のエラーがスローされますか?
- このアプローチが機能しない理由と私はここで何が欠けているのか理解したいと思います。
ドキュメントから:*はじめに:読み込みモジュールをルートアプリケーションモジュール*にインポートします。どうしてそんなことをしないの? –
動作しません。私はそれをやってみた。私の基本的なプロジェクトは、ルートアプリケーションモジュールを持っているng2-admin(https://github.com/akveo/ng2-admin)から派生していると言いました。 (私の例ではログインモジュール) – nitinsh99
私の最後のコメントを追加するには:自分のアプリケーションのルートモジュール(app.module.ts)にsharedModulesを追加しようとしましたどちらもうまくいきません。 – nitinsh99