0

I use EditableComponent from EditableComponent Link

declarations [EditableComponent,ViewModeDirective,EditModeDirective,EditableOnEnterDirective] in appModule have work

but

declarations [EditableComponent,ViewModeDirective,EditModeDirective,EditableOnEnterDirective] in SharedModule

imports[SharedModule] in appModule not work

module SharedModule

import { NgModule } from '@angular/core';

import { EditableComponent } from './table-edittable/editable.component';
import { ViewModeDirective } from './table-edittable/view-mode.directive';
import { EditModeDirective } from './table-edittable/edit-mode.directive';
import { EditableOnEnterDirective } from './table-edittable/editable-on-enter.directive';

@NgModule({
  declarations: [EditableComponent,ViewModeDirective,EditModeDirective,EditableOnEnterDirective],
  exports: [EditableComponent,ViewModeDirective,EditModeDirective,EditableOnEnterDirective]
})
export class SharedDeclarationsModule {
}

module appModule

import {SharedDeclarationsModule}from '../../layout-module/shared.declarstions.module';


@NgModule({
  declarations: [UserComponent,LeftsideComponent,DetailComponent,
    FocusableDirective,
  ],
  imports: [BrowserModule,HttpClientModule,CommonModule,
    SharedModule,
    MatCheckboxModule,
    FormsModule,
    MatGridListModule,
    SharedDeclarationsModule
  ],
  exports:[UserComponent,LeftsideComponent,DetailComponent,SharedDeclarationsModule]
})
export class UserModule { }

Which part is wrong?

Sorry for not describing 'not work' I represent with pictures:

not work img:

enter image description here

have work img:

enter image description here

1
  • Please be more specific. What does it mean "it doesn't work"?. Could you share the output from your ng build command so we can help you troubleshoot? Commented Nov 15, 2021 at 8:20

1 Answer 1

0

You need to import CommonModule and export it. You can follow the documentation for creating a shared module. https://angular.io/guide/sharing-ngmodules

imports:      [ CommonModule ],
Sign up to request clarification or add additional context in comments.

2 Comments

It succeeded! I tried for a long time. It turned out that the problem was just this.. Thank you!
Glad to hear that. Check this answer so others can know that this is the correct one and worked for you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.