Component is part of the declaration of 2 modules

前端 未结 16 758
我在风中等你
我在风中等你 2020-12-04 06:44

I try to build an ionic 2 app. When I try the app in the browser with ionic serve or launch it on an emulator everything works fine.

But when I try to build it every

16条回答
  •  孤城傲影
    2020-12-04 07:31

    Some people using Lazy loading are going to stumble across this page.

    Here is what I did to fix sharing a directive.

    1. create a new shared module

    shared.module.ts

    import { NgModule, Directive,OnInit, EventEmitter, Output, OnDestroy, Input,ElementRef,Renderer } from '@angular/core';
    import { CommonModule } from '@angular/common';
    
    import { SortDirective } from './sort-directive';
    
    @NgModule({
      imports: [
      ],
      declarations: [
      SortDirective
      ],
      exports: [
        SortDirective
      ]
    })
    
    export class SharedModule { }
    

    Then in app.module and your other module(s)

    import {SharedModule} from '../directives/shared.module'
    ...
    
    @NgModule({
       imports: [
           SharedModule
           ....
           ....
     ]
    })
    export class WhateverModule { }
    

提交回复
热议问题