> For the complete documentation index, see [llms.txt](https://enappd-apps.gitbook.io/apps/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://enappd-apps.gitbook.io/apps/ionic-4-full-app/how-to-use-this-template/shared-component-and-modules.md).

# Shared Component & Modules

Handling the sharing of common code

## Shared Modules

In some cases, the pages use **Shared modules.** For example, the Instagram Home page and Profile page contains the component `instagram` which is the scrollable images gallery, imported from `src/app/components` using `shared-module.module.ts` . This type of sharing is useful where the same component is required in multiple pages.

If you want to use any of these common components outside of the copied module, just move the `shared-module.module.ts` to a parent directory level, and then share the component via it.&#x20;

Imported components look like an HTML tag, something like this

```
<instagram></instagram>
```

Read more about routing in Angular in [official documentation here](https://angular.io/guide/routing-overview).

## Shared Components

To modularize and make code in smaller pieces, some code pieces are put as **components.** These components make it easy to separate small feature development, and handle each individually.&#x20;

For example, the layout-components -> card-sliders-layout -> components has 5 components which are further used in `sliders` page in the same module. Since the components are used only in one page, there is no need of a shared module. The component can just be imported in the `module.ts` file of the page, and then can be used in the page HTML as `<app-slider1></app-slider1>` etc.

![](https://3065094597-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La-kqVz2Uq1Ka0VUWZT%2F-McyAEMtfjQMaKgvlMv_%2F-Mcye2-cWXNtmMuAhPyy%2FScreen%20Shot%202021-06-24%20at%2011.34.02%20AM.png?alt=media\&token=763a5643-0cca-4eba-8f7d-2a9a2bfeb022)

##
