2019-12-02 20:47:19 +00:00
# Overview of Angular libraries
2018-12-05 21:29:31 +00:00
Many applications need to solve the same general problems, such as presenting a unified user interface, presenting data, and allowing data entry.
2021-05-10 17:51:50 +00:00
Developers can create general solutions for particular domains that can be adapted for re-use in different applications.
2018-12-05 21:29:31 +00:00
Such a solution can be built as Angular *libraries* and these libraries can be published and shared as *npm packages* .
2021-05-10 17:51:50 +00:00
An Angular library is an Angular [project ](guide/glossary#project ) that differs from an application in that it cannot run on its own.
A library must be imported and used in an application.
2018-12-05 21:29:31 +00:00
2022-10-05 20:17:47 +00:00
Libraries extend Angular's base features.
For example, to add [reactive forms ](guide/reactive-forms ) to an application, add the library package using `ng add @angular/forms` , then import the `ReactiveFormsModule` from the `@angular/forms` library in your application code.
docs: improve markdown (#45325)
The purpose of the changes is to clean all markdown to match a single pedantic style.
* To ensure all changes in style are properly separated.
* To ensure all styled content aligns to nearest 4-character-tab.
* To ensure all code blocks use the Angular `<code-example>` or `<code-tab>` elements.
* To ensure all markdown exists outside of html tags.
* To ensure all images use the Angular style for `<img>` elements.
* To ensure that all smart punctuation is replaced or removed.
```text
’, ’, “, ”, –, —, …
```
* To ensure all content does not conflict with the following reserved characters.
```text
@, $, *, &, #, |, <, >,
```
* To ensure all content displays using html entities.
The following changes were made to files in the following directory.
```text
aio/content
```
The target files were markdown files.
The list of excluded files:
```text
.browserslistrc, .css, .conf, .editorconfig, .gitignore, .html, .js, .json, .sh, .svg, .ts, .txt, .xlf,
```
PR Close #45325
2022-03-10 16:48:09 +00:00
Similarly, adding the [service worker ](guide/service-worker-intro ) library to an Angular application is one of the steps for turning an application into a [Progressive Web App ](https://developers.google.com/web/progressive-web-apps ) \(PWA\).
[Angular Material ](https://material.angular.io ) is an example of a large, general-purpose library that provides sophisticated, reusable, and adaptable UI components.
2018-12-05 21:29:31 +00:00
docs: improve markdown (#45325)
The purpose of the changes is to clean all markdown to match a single pedantic style.
* To ensure all changes in style are properly separated.
* To ensure all styled content aligns to nearest 4-character-tab.
* To ensure all code blocks use the Angular `<code-example>` or `<code-tab>` elements.
* To ensure all markdown exists outside of html tags.
* To ensure all images use the Angular style for `<img>` elements.
* To ensure that all smart punctuation is replaced or removed.
```text
’, ’, “, ”, –, —, …
```
* To ensure all content does not conflict with the following reserved characters.
```text
@, $, *, &, #, |, <, >,
```
* To ensure all content displays using html entities.
The following changes were made to files in the following directory.
```text
aio/content
```
The target files were markdown files.
The list of excluded files:
```text
.browserslistrc, .css, .conf, .editorconfig, .gitignore, .html, .js, .json, .sh, .svg, .ts, .txt, .xlf,
```
PR Close #45325
2022-03-10 16:48:09 +00:00
Any application developer can use these and other libraries that have been published as npm packages by the Angular team or by third parties.
See [Using Published Libraries ](guide/using-libraries ).
2018-12-05 21:29:31 +00:00
## Creating libraries
2022-10-05 20:17:47 +00:00
If you have developed features that are suitable for reuse, you can create your own libraries.
2018-12-05 21:29:31 +00:00
These libraries can be used locally in your workspace, or you can publish them as [npm packages ](guide/npm-packages ) to share with other projects or other Angular developers.
These packages can be published to the npm registry, a private npm Enterprise registry, or a private package management system that supports npm packages.
See [Creating Libraries ](guide/creating-libraries ).
2022-10-05 20:17:47 +00:00
Deciding to package features as a library is an architectural decision. It is comparable to deciding whether a feature is a component or a service, or deciding on the scope of a component.
2018-12-05 21:29:31 +00:00
2022-10-05 20:17:47 +00:00
Packaging features as a library forces the artifacts in the library to be decoupled from the application's business logic.
2018-12-05 21:29:31 +00:00
This can help to avoid various bad practices or architecture mistakes that can make it difficult to decouple and reuse code in the future.
2021-05-10 17:51:50 +00:00
Putting code into a separate library is more complex than simply putting everything in one application.
2018-12-05 21:29:31 +00:00
It requires more of an investment in time and thought for managing, maintaining, and updating the library.
2022-10-05 20:17:47 +00:00
This complexity can pay off when the library is being used in multiple applications.
2019-01-31 18:06:27 +00:00
< div class = "alert is-helpful" >
docs: improve markdown (#45325)
The purpose of the changes is to clean all markdown to match a single pedantic style.
* To ensure all changes in style are properly separated.
* To ensure all styled content aligns to nearest 4-character-tab.
* To ensure all code blocks use the Angular `<code-example>` or `<code-tab>` elements.
* To ensure all markdown exists outside of html tags.
* To ensure all images use the Angular style for `<img>` elements.
* To ensure that all smart punctuation is replaced or removed.
```text
’, ’, “, ”, –, —, …
```
* To ensure all content does not conflict with the following reserved characters.
```text
@, $, *, &, #, |, <, >,
```
* To ensure all content displays using html entities.
The following changes were made to files in the following directory.
```text
aio/content
```
The target files were markdown files.
The list of excluded files:
```text
.browserslistrc, .css, .conf, .editorconfig, .gitignore, .html, .js, .json, .sh, .svg, .ts, .txt, .xlf,
```
PR Close #45325
2022-03-10 16:48:09 +00:00
**NOTE**: < br / >
Libraries are intended to be used by Angular applications.
2022-10-05 20:17:47 +00:00
To add Angular features to non-Angular web applications, use [Angular custom elements ](guide/elements ).
2019-01-31 18:06:27 +00:00
< / div >
docs: improve markdown (#45325)
The purpose of the changes is to clean all markdown to match a single pedantic style.
* To ensure all changes in style are properly separated.
* To ensure all styled content aligns to nearest 4-character-tab.
* To ensure all code blocks use the Angular `<code-example>` or `<code-tab>` elements.
* To ensure all markdown exists outside of html tags.
* To ensure all images use the Angular style for `<img>` elements.
* To ensure that all smart punctuation is replaced or removed.
```text
’, ’, “, ”, –, —, …
```
* To ensure all content does not conflict with the following reserved characters.
```text
@, $, *, &, #, |, <, >,
```
* To ensure all content displays using html entities.
The following changes were made to files in the following directory.
```text
aio/content
```
The target files were markdown files.
The list of excluded files:
```text
.browserslistrc, .css, .conf, .editorconfig, .gitignore, .html, .js, .json, .sh, .svg, .ts, .txt, .xlf,
```
PR Close #45325
2022-03-10 16:48:09 +00:00
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28