B
B
bormor2019-05-09 11:17:48
Angular
bormor, 2019-05-09 11:17:48

How is Angular configuring the scope of components in multiple modules (using a small code example)?

I work with Angular, after React. Some moments are unusual
Question:
There is a component, in its html template another component is used, which is NOT included in the angular module of this functionality block.
But this shared component is listed in shared.modules.js in the exports block.
Do I understand correctly:
the components specified in the ng module in the declarations block will be visible only in the components of this module ; the
components specified in the ng module in the exports block will be visible in the components of those modules that import the module with exports?
Code to illustrate
github link in component
github link in shared.modules.js

// article.component.html
<div class="article-page">

  <div class="banner">
    <div class="container">
      <h1>{{ article.title }}</h1>

      <app-article-meta [article]="article">  // где это подключается?

      </app-article-meta>
    </div>
  </div>

// article-module.js
...
@NgModule({

  declarations: [  // в коде этого модуля компонент не объявляется
    ArticleComponent,
    ArticleCommentComponent, 
    MarkdownPipe
  ],

})
export class ArticleModule {}

// shared.module.ts
...
@NgModule({

  exports: [  // зато компонент указан в exports этого модуля
    ArticleMetaComponent,
    ...
  ],

})
export class ArticleModule {}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question