yisraelx / ngx-showdown

Angular (>=2) integration for Showdown
http://yisraelx.github.io/ngx-showdown
MIT License
16 stars 13 forks source link

Parent child module #3

Closed windmaomao closed 7 years ago

windmaomao commented 7 years ago

@yisraelx, thanks for the component. Very nice.

I run into an issue today. If I define MdModule and include it in AppModule

@NgModule({
  imports: [
    BrowserModule,

    // Third party
    MdModule,

    // Features
    BlogModule
  ],
})
export class AppModule { }

I couldn't get md directive inside BlogModule. Am I doing anything wrong, because I normally get this type of inheritance. I did notice some other module is using

    NgLoadingBarModule.forRoot(),

I wonder if this is the reason here.

yisraelx commented 7 years ago

I think there is no inheritance of the components between the modules, and each module you must provide his own components.

import { MdModule } from 'ng2-md';
import { NgModule } from '@angular/core';
@NgModule({
  imports: [ NgModule ]
})
export class BlogModule{}

@NgModule({
  imports: [
    BrowserModule,

    // Third party
    MdModule,

    // Features
    BlogModule
  ],
})
export class AppModule { }

And forRoot method is for an easy configuration of the module.

After the issue #2 , I was thinking maybe add it for easy configuration of 'ConverterOptions'.

import { MdModule, ConverterOptions, IConverterConstructorOptions } from 'ng2-md';
import { NgModule } from '@angular/core';

@NgModule({
  imports: [
    MdModule.forRoot({...} as ConverterOptions | IConverterConstructorOptions)
  ]
})
export class AppModule { }

Maybe I added it to the next release.

yisraelx commented 7 years ago

I made the change: @56f2186795345dca7f949f4b657a3f689d654426 - add 'forRoot' method to MdModule