{"id":27750,"date":"2020-01-08T00:00:00","date_gmt":"2020-01-07T23:00:00","guid":{"rendered":"https:\/\/blexin.com\/creare-librerie-di-componenti-angular\/"},"modified":"2021-05-20T18:44:46","modified_gmt":"2021-05-20T16:44:46","slug":"creating-angular-components-libraries","status":"publish","type":"post","link":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/","title":{"rendered":"Creating Angular components libraries"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"608\" data-attachment-id=\"27729\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/attachment\/image00-15-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?fit=1024%2C608&amp;ssl=1\" data-orig-size=\"1024,608\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image00-15\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?fit=1024%2C608&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?resize=1024%2C608&#038;ssl=1\" alt=\"\" class=\"wp-image-27729\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png 1024w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15-980x582.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15-480x285.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">It often happens we need to solve a problem already solved in a previous project using a simple copy and paste of the code. This is a fast and easy solution, but it may cause secondary effects, the worst of whom is the discovery of a bug that needs to be corrected in all projects where we passed the code. What if I want to add new functionality? Should I propagate it all over?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In all Angular projects I worked on, it was always necessary to create a component able to pick up data and show them in table format. Why don\u2019t we make this component usable for more than one project? Angular gives us this opportunity with&nbsp;<strong>Angular Library<\/strong>. In my&nbsp;<a href=\"https:\/\/www.blexin.com\/en-US\/Article\/Blog\/Managing-the-drag--drop-in-Angular-54\" target=\"_blank\" rel=\"noreferrer noopener\">previous article<\/a>, I showed you how to create a component able to display data in table format and that allows the drag and drop of columns: let\u2019s make this component reusable in all our projects with a library!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From the Angular&nbsp;<strong>CLI<\/strong>&nbsp;we launch following commands:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>ng new BlexinLibrary<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Regarding the creation of a library, the official Angular documentation indicates to set the flag&nbsp;<code>--create-application<\/code>&nbsp;to false to indicate to the CLI it does not have to create an initial application but only an empty workspace. This is not the solution I choose, nor the one I prefer because it makes it difficult to make the debug of the library.<br>I suggest you create a classical Angular application working as a host and develop the library inside it so that you can test it before the release. In the project root folder, let\u2019s launch the command to create a library:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>ng generate library DataTable<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"474\" height=\"666\" data-attachment-id=\"27734\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/attachment\/image01-11-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-11.png?fit=474%2C666&amp;ssl=1\" data-orig-size=\"474,666\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image01-11\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-11.png?fit=474%2C666&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-11.png?resize=474%2C666&#038;ssl=1\" alt=\"\" class=\"wp-image-27734\" srcset=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-11.png?w=474&amp;ssl=1 474w, https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-11.png?resize=214%2C300&amp;ssl=1 214w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Note that the Angular CLI created a project folder; inside it, we can find a folder with the name of the library (Data Table). In the sub-folder data-table\/src, we find a folder&nbsp;<em>lib<\/em>, which contains files that compose the project (components, services, modules, etc.), together with a file public-api.ts that declares what we want to make available inside our library.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/*\n* Public API Surface of data-table\n*\/\n  \nexport * from &#039;.\/lib\/data-table.service&#039;;\nexport * from &#039;.\/lib\/data-table.component&#039;;\nexport * from &#039;.\/lib\/data-table.module&#039;;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">We find out that in the library, a component, a service, and a module have already been created. The configuration file of the whole workspace,<strong>&nbsp;angular.json<\/strong>, is updated with a new&nbsp;<strong>library<\/strong>-type project, which has the name we choose during the creation of the library.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n{\n\u00a0&quot;$schema&quot;: &quot;.\/node_modules\/@angular\/cli\/lib\/config\/schema.json&quot;,\n\u00a0&quot;version&quot;: 1,\n\u00a0&quot;newProjectRoot&quot;: &quot;projects&quot;,\n\u00a0&quot;projects&quot;: {\n\u00a0\u00a0\u00a0&quot;BlexinLibrary&quot;: {\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;root&quot;: &quot;&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;sourceRoot&quot;: &quot;src&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;projectType&quot;: &quot;application&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;prefix&quot;: &quot;app&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0...\n\u00a0\u00a0\u00a0},\n\u00a0\u00a0\u00a0&quot;BlexinLibrary-e2e&quot;: {\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;root&quot;: &quot;e2e\/&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;projectType&quot;: &quot;application&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;prefix&quot;: &quot;&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0...\n\u00a0\u00a0\u00a0},\n\u00a0\u00a0\u00a0&quot;DataTable&quot;: {\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;root&quot;: &quot;projects\/data-table&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;sourceRoot&quot;: &quot;projects\/data-table\/src&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;projectType&quot;: &quot;library&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;prefix&quot;: &quot;lib&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;architect&quot;: {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;build&quot;: {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;builder&quot;: &quot;@angular-devkit\/build-ng-packagr:build&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;options&quot;: {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;tsConfig&quot;: &quot;projects\/data-table\/tsconfig.lib.json&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;project&quot;: &quot;projects\/data-table\/ng-package.json&quot;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0},\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Now we can proceed with writing the code as in a standard Angular project. Taking the cue from my&nbsp;<a href=\"https:\/\/www.blexin.com\/en-US\/Article\/Blog\/Managing-the-drag--drop-in-Angular-54\" target=\"_blank\" rel=\"noreferrer noopener\">previous article<\/a>, we delete the file that created the CLI and leave the&nbsp;<em><strong>data-table.component.ts<\/strong><\/em>&nbsp;and the&nbsp;<em><strong>data-table.module.ts<\/strong><\/em>, and we move on to the construction of the component.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the previous article, the table was not an independent component, but it was part of the app.component: therefore, we need to extract the component data-table from the app.component.<br>Looking at the template, we find that the data-table basically operates on two data structures:&nbsp;<strong>columns<\/strong>&nbsp;and&nbsp;<strong>rows<\/strong>. Both these data structures must be supplied from library users, becoming our&nbsp;<strong>Input<\/strong>. The .ts file of our component will be:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nimport { Component, Input } from &#039;@angular\/core&#039;;\n  \n@Component({\n selector: &#039;blx-data-table&#039;,\n templateUrl: &#039;.\/data-table.component.html&#039;,\n styleUrls: &#x5B;&#039;.\/data-table.component.css&#039;]\n})\nexport class DataTableComponent {\n @Input() columns: string&#x5B;];\n @Input() rows: any&#x5B;];\n  \n constructor() { }\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">We modify the selector from&nbsp;<strong>lib-DataTable<\/strong>&nbsp;to&nbsp;<strong>blx-data-table<\/strong>, and we modify the prefix in the file tslint.json:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n{\n\u00a0&quot;extends&quot;: &quot;..\/..\/tslint.json&quot;,\n\u00a0&quot;rules&quot;: {\n\u00a0\u00a0\u00a0&quot;directive-selector&quot;: &#x5B;\n\u00a0\u00a0\u00a0\u00a0\u00a0true,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;attribute&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;blx&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;camelCase&quot;\n\u00a0\u00a0\u00a0],\n\u00a0\u00a0\u00a0&quot;component-selector&quot;: &#x5B;\n\u00a0\u00a0\u00a0\u00a0\u00a0true,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;element&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;blx&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;kebab-case&quot;\n\u00a0\u00a0\u00a0]\n\u00a0}\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">You can see below the template of our component:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;div class=&quot;p-5 m-5&quot;&gt;\n\u00a0&lt;div class=&quot;p-5 m-5&quot;&gt;\n\u00a0&lt;div class=&quot;table-responsive table-container&quot;&gt;\n\u00a0\u00a0\u00a0&lt;table class=&quot;table&quot;&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0&lt;thead class=&quot;thead-dark&quot;&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;tr dragula=&quot;table_columns&quot; &#x5B;(dragulaModel)]=&quot;columns&quot;&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;th *ngFor=&quot;let column of columns&quot;&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{{column}}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/th&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/tr&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/thead&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0&lt;tbody&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;tr *ngFor=&quot;let row of rows&quot;&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;td *ngFor=&quot;let column of columns&quot;&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{{row&#x5B;column]}}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/td&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/tr&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/tbody&gt;\n\u00a0\u00a0\u00a0&lt;\/table&gt;\n\u00a0&lt;\/div&gt;\n&lt;\/div&gt;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">The external library we are using for the drag&amp;drop needs some CSS classes to show the desired effect. In the previous project, I put these classes in the&nbsp;<strong>style.css<\/strong>. Now I don\u2019t want anyone importing the library to have to worry about adding such classes to his\/her project: they must be present in the library.<br>We include them in the file&nbsp;<strong>data-table.component.css<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As I wrote, the file&nbsp;<strong>public_api.ts<\/strong>&nbsp;allows us to define what our users will see in the library. We must modify it to adjust it to the previously made service cancellation.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nexport * from &#039;.\/lib\/data-table.component&#039;;\nexport * from &#039;.\/lib\/data-table.module&#039;;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">The component&nbsp;<strong>data-table<\/strong>&nbsp;requires some external dependencies:&nbsp;<code>ng2-dragula<\/code>&nbsp;(drag&amp;drop management) and&nbsp;<code>bootstrap<\/code>&nbsp;(CSS classes). We need to inform those who install the library that, to guarantee the right functioning, the addition of these dependencies to their project is needed. We modify then the file&nbsp;<strong>package.json<\/strong>&nbsp;in the data-table folder, adding to it the section&nbsp;<em><strong>peerDependencies<\/strong><\/em>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n{\n\u00a0&quot;name&quot;: &quot;data-table&quot;,\n\u00a0&quot;version&quot;: &quot;0.0.1&quot;,\n\u00a0&quot;peerDependencies&quot;: {\n\u00a0\u00a0\u00a0&quot;@angular\/common&quot;: &quot;^7.0.0&quot;,\n\u00a0\u00a0\u00a0&quot;@angular\/core&quot;: &quot;^7.0.0&quot;,\n\u00a0\u00a0\u00a0&quot;bootstrap&quot;: &quot;^4.3.1&quot;,\n\u00a0\u00a0\u00a0&quot;ng2-dragula&quot;: &quot;^2.1.1&quot;\n\u00a0}\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Before the publication, we must be sure that everything is working fine. The initial choice to create an Angular project and not an empty workspace now gives us a significant advantage: to test the library, we only need to import its module in our app.module and use the component through the selector. This is how our&nbsp;<strong>app.component.html<\/strong>&nbsp;becomes:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;div style=&quot;text-align:center&quot;&gt;\n\u00a0&lt;h1&gt;\n\u00a0\u00a0\u00a0Welcome to {{ title }}!\n\u00a0&lt;\/h1&gt;\n&lt;\/div&gt;\n&lt;blx-data-table &#x5B;columns]=&quot;columns&quot; &#x5B;rows]=&quot;rows&quot;&gt;&lt;\/blx-data-table&gt;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">where columns and rows are defined in&nbsp;<em><strong>app.component.ts<\/strong><\/em>&nbsp;and then passed in input to the&nbsp;<strong>data-table<\/strong>. Before we can launch our application, we need to install both dependencies in our library (with instructions&nbsp;<code>npm install ng2-dragula<\/code>&nbsp;and&nbsp;<code>npm install bootstrap<\/code>), add&nbsp;<code>\"node_modules\/bootstrap\/dist\/css\/bootstrap.css\"<\/code>&nbsp;among the styles of our&nbsp;<strong>angular.json<\/strong>&nbsp;and in the end add&nbsp;<code>(window as any).global = window;<\/code>&nbsp;in the&nbsp;<strong>polyfills.ts<\/strong>&nbsp;file, as suggested in the Dragula documentation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We launch then the application with&nbsp;<code>ng serve<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"376\" data-attachment-id=\"27739\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/attachment\/image02-10-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-10.png?fit=2612%2C958&amp;ssl=1\" data-orig-size=\"2612,958\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image02-10\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-10.png?fit=1024%2C376&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-10.png?resize=1024%2C376&#038;ssl=1\" alt=\"\" class=\"wp-image-27739\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-10-980x359.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-10-480x176.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">As we verified that everything is working fine, we can distribute it. Let\u2019s compile the library and add the name of the library to the build command:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>ng build DataTable<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When we finish compiling, the library will be available in the dist folder.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to use the newly created library<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We have two options: we can import it in a new project collecting it form its dist folder, or we can make it available together with its updates using the same ecosystem chosen by Angular: npm.<br>Let\u2019s create a new Angular project:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>ng new demo-with-lib<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inside the structure of the just created project, we create a new lib folder, where we copy the folder containing the result of the build of the library. I can then install it with the command:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>npm i .\/libs\/data-table<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we also add the dependencies required for the right functioning and import the module&nbsp;<code>DataTableModule<\/code>&nbsp;in the<em>&nbsp;app.module.ts<\/em>&nbsp;to use the exposed component.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nimport { BrowserModule } from &#039;@angular\/platform-browser&#039;;\nimport { NgModule } from &#039;@angular\/core&#039;;\nimport { DataTableModule } from &#039;data-table&#039;;\nimport { AppComponent } from &#039;.\/app.component&#039;;\n\u00a0\u00a0\n@NgModule({\n\u00a0declarations: &#x5B;\n\u00a0\u00a0\u00a0AppComponent\n\u00a0],\n\u00a0imports: &#x5B;\n\u00a0\u00a0\u00a0BrowserModule,\n\u00a0\u00a0\u00a0DataTableModule\n\u00a0],\n\u00a0providers: &#x5B;],\n\u00a0bootstrap: &#x5B;AppComponent]\n})\nexport class AppModule { }\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">We position the component with the proper tag&nbsp;<code>blx-data-table<\/code>&nbsp;in the&nbsp;<em>app.component.ts<\/em>&nbsp;providing expected inputs:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;div class=&quot;text-center&quot;&gt;\n\u00a0&lt;h1&gt;\n\u00a0\u00a0\u00a0Welcome to {{ title }}!\n\u00a0&lt;\/h1&gt;\n&lt;\/div&gt;\n&lt;blx-data-table &#x5B;columns]=&quot;columns&quot; &#x5B;rows]=&quot;rows&quot;&gt; &lt;\/blx-data-table&gt;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s launch the application and verify that is working fine.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"376\" data-attachment-id=\"27742\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/attachment\/image02-1-1-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-1-1.png?fit=2612%2C958&amp;ssl=1\" data-orig-size=\"2612,958\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image02-1-1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-1-1.png?fit=1024%2C376&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-1-1.png?resize=1024%2C376&#038;ssl=1\" alt=\"\" class=\"wp-image-27742\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-1-1-980x359.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-1-1-480x176.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We have made progress: we can reuse the component everywhere we want. Actually, we have used the copy and paste again: not of the source code, but of the library distribution folder. What if we want other members of a team to use the library, providing them with a simple tool to follow its updates? What if I want to make it public, that\u2019s to say permit anybody all over the world to install it via npm?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At the address&nbsp;<a href=\"https:\/\/docs.npmjs.com\/creating-and-publishing-private-packages\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.npmjs.com\/creating-and-publishing-private-packages&nbsp;<\/a>, is available an official tutorial to publish a package on a public npm registry. We will follow a different path offered by GitHub over the past few months.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">GitHub gives the chance to create our own repository thanks to&nbsp;<strong>GitHub Packages<\/strong>, where you can publish and distribute your library in private or public mode.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to publish on GitHub Packages<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In order to publish, install, and eventually delete a package from GitHub Packages, an access token is required. There are two ways to obtain one: using the personal Access Token with your username to authenticate on GitHub or using a GITHUB_TOKEN to authenticate on GitHub Actions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I choose the personal access token. We need then to modify the file&nbsp;<em><strong>~\/.npmrc<\/strong><\/em>&nbsp;and insert the following line:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>\/\/npm.pkg.github.com\/:_authToken=TOKEN<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">and substitute \u201cTOKEN\u201d with your own token.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we need to create the file&nbsp;<em><strong>.npmrc<\/strong><\/em>&nbsp;in the same folder where the package.json is present and insert the following line:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>registry=https:\/\/npm.pkg.github.com\/OWNER<\/code><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n{\u00a0\u00a0 \n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;name&quot;: &quot;@accountgit\/packagename&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;version&quot;: &quot;2.0.1&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;peerDependencies&quot;: {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;@angular\/common&quot;: &quot;^8.2.14&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;@angular\/core&quot;: &quot;^8.2.14&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;bootstrap&quot;: &quot;^4.3.1&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;ng2-dragula&quot;: &quot;^2.1.1&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0...\n\u00a0\u00a0\u00a0\u00a0\u00a0},\n\u00a0\u00a0\u00a0\u00a0\u00a0&quot;repository&quot;: {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;type&quot;: &quot;git&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;url&quot;: &quot;git+https:\/\/github.com\/accountgit\/reponame.git&quot;\n\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">We can then publish it with the command:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$ npm publish<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"237\" data-attachment-id=\"27745\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/attachment\/image03-9-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-9.png?fit=1518%2C351&amp;ssl=1\" data-orig-size=\"1518,351\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image03-9\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-9.png?fit=1024%2C237&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-9.png?resize=1024%2C237&#038;ssl=1\" alt=\"\" class=\"wp-image-27745\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-9-980x227.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-9-480x111.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After the publication, we can find in our repository that the section package is populated, and it brings us a more detailed section on what has been published.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"362\" data-attachment-id=\"27748\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/attachment\/image04-10-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-10.png?fit=1582%2C559&amp;ssl=1\" data-orig-size=\"1582,559\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image04-10\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-10.png?fit=1024%2C362&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-10.png?resize=1024%2C362&#038;ssl=1\" alt=\"\" class=\"wp-image-27748\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-10-980x346.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-10-480x170.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">How to modify the library<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">How can we manage the normal life cycle of our library, such as the correction of bugs, the addition of new features, a substantial modification that makes it incompatible with previous versions? All this, allowing anyone who has installed the library to update the package in their projects safely.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It\u2019s time to manage the versioning of my library. In the package.json we find the field&nbsp;<strong>version<\/strong>, which defines the current version of the library. Using Semantic Version, we can clarify to those who use our library, which versions of our package can be installed safely, that is with no need to modify your code to integrate our library.<br>In this way, the version field contains a string formatted as \u201c<strong>major.minor.patch<\/strong>\u201d, where every block corresponds to a non-negative whole number. In the&nbsp;<a href=\"https:\/\/www.blexin.com\/en-US\/Article\/Blog\/Versioning-of-Nuget-packages-with-GitFlow-and-SemVer-41\" target=\"_blank\" rel=\"noreferrer noopener\">article by Antonio&nbsp;<\/a>, you can find more information.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s come back to our modification: to solve our bugs, we must modify the&nbsp;<em>patch<\/em>&nbsp;of our version number, increasing by one. After adding a new functionality compatible with the current code, we need likewise to update<em>&nbsp;minor<\/em>, increasing it by one.&nbsp;<em>Major<\/em>&nbsp;will be incremented when we make modifications that affect the API, as, in our case, the modification of the name of an INPUT property. As soon as we finish the modifications, we can publish the updated package, using the same command used before&nbsp;<code>$ npm publish<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Regarding the clients using our library, following the command&nbsp;<code>npm install<\/code>, its update (get with the command&nbsp;<code>npm update<\/code>) depends on the configuration of the dependency in the package.json.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We have two possible configurations:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\u201cname_of_package\u201d: \u201c~major.minor.patch\u201d<\/strong><\/li><li><strong>\u201cname_of_package\u201d: \u201c^major.minor.patch\u201d<\/strong><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If you choose the first option, you download the package with the same major and minor, but with the last patch version available If you choose the second option, you download the package with the same major, but with the last minor and patch available version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using the<strong>&nbsp;tilde(~)<\/strong>, we are indicating we want to keep our package except in case of a bug fix. Using the&nbsp;<strong>caret(^)<\/strong>, we are indicating we want to update the package even in case of addition of new functionalities compatible with the currently installed version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note that if you still didn\u2019t install the package,&nbsp;<code>npm install<\/code>&nbsp;will have the same effect of&nbsp;<code>npm update<\/code>, that is, it will find the last updated package, based on given guidelines in the package.json. It will be different if we already install packages locally: in this case, the&nbsp;<code>npm install<\/code>&nbsp;is not enough to update the package, because the local one already follows given guidelines, then you have to use&nbsp;<code>npm update<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the end, it is possible to specify if you want to install the last available version, independently of the one installed with the command&nbsp;<code>$ npm install packagename@latest \u2013save<\/code>. You can then obtain the update of the package.json with the version number of the downloaded package.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The code is available on github to the following address:&nbsp;<a href=\"https:\/\/github.com\/AARNOLD87\/AngularLibrary\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/AARNOLD87\/AngularLibrary<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">See you at&nbsp;the next article!<\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s see how reuse our components in different projects with Angular libraries<\/p>\n","protected":false},"author":196716250,"featured_media":27729,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_crdt_document":"","inline_featured_image":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[688637524],"tags":[688637390],"class_list":["post-27750","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-en","tag-angular-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Creating Angular components libraries - Blexin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating Angular components libraries - Blexin\" \/>\n<meta property=\"og:description\" content=\"Let\u2019s see how reuse our components in different projects with Angular libraries\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/\" \/>\n<meta property=\"og:site_name\" content=\"Blexin\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-07T23:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-20T16:44:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i2.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?fit=1024%2C608&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"608\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Adolfo Arnold\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Adolfo Arnold\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/\"},\"author\":{\"name\":\"Adolfo Arnold\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#\\\/schema\\\/person\\\/0de430b61c8a48b0e9d81308817c1517\"},\"headline\":\"Creating Angular components libraries\",\"datePublished\":\"2020-01-07T23:00:00+00:00\",\"dateModified\":\"2021-05-20T16:44:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/\"},\"wordCount\":1859,\"image\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/image00-15.png?fit=1024%2C608&ssl=1\",\"keywords\":[\"Angular\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/\",\"url\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/\",\"name\":\"Creating Angular components libraries - Blexin\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/image00-15.png?fit=1024%2C608&ssl=1\",\"datePublished\":\"2020-01-07T23:00:00+00:00\",\"dateModified\":\"2021-05-20T16:44:46+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#\\\/schema\\\/person\\\/0de430b61c8a48b0e9d81308817c1517\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/image00-15.png?fit=1024%2C608&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/image00-15.png?fit=1024%2C608&ssl=1\",\"width\":1024,\"height\":608},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/creating-angular-components-libraries\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blexin.com\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating Angular components libraries\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/blexin.com\\\/en\\\/\",\"name\":\"Blexin\",\"description\":\"Con noi \u00e8 semplice\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blexin.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#\\\/schema\\\/person\\\/0de430b61c8a48b0e9d81308817c1517\",\"name\":\"Adolfo Arnold\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ff2a87b54d0f130d7452164533199af05ef16dbd08b9241729946cea0eec7cca?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ff2a87b54d0f130d7452164533199af05ef16dbd08b9241729946cea0eec7cca?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ff2a87b54d0f130d7452164533199af05ef16dbd08b9241729946cea0eec7cca?s=96&d=identicon&r=g\",\"caption\":\"Adolfo Arnold\"},\"url\":\"https:\\\/\\\/blexin.com\\\/en\\\/author\\\/adolfo-arnoldblexin-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating Angular components libraries - Blexin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/","og_locale":"en_US","og_type":"article","og_title":"Creating Angular components libraries - Blexin","og_description":"Let\u2019s see how reuse our components in different projects with Angular libraries","og_url":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/","og_site_name":"Blexin","article_published_time":"2020-01-07T23:00:00+00:00","article_modified_time":"2021-05-20T16:44:46+00:00","og_image":[{"width":1024,"height":608,"url":"https:\/\/i2.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?fit=1024%2C608&ssl=1","type":"image\/png"}],"author":"Adolfo Arnold","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Adolfo Arnold","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/#article","isPartOf":{"@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/"},"author":{"name":"Adolfo Arnold","@id":"https:\/\/blexin.com\/en\/#\/schema\/person\/0de430b61c8a48b0e9d81308817c1517"},"headline":"Creating Angular components libraries","datePublished":"2020-01-07T23:00:00+00:00","dateModified":"2021-05-20T16:44:46+00:00","mainEntityOfPage":{"@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/"},"wordCount":1859,"image":{"@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?fit=1024%2C608&ssl=1","keywords":["Angular"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/","url":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/","name":"Creating Angular components libraries - Blexin","isPartOf":{"@id":"https:\/\/blexin.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/#primaryimage"},"image":{"@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?fit=1024%2C608&ssl=1","datePublished":"2020-01-07T23:00:00+00:00","dateModified":"2021-05-20T16:44:46+00:00","author":{"@id":"https:\/\/blexin.com\/en\/#\/schema\/person\/0de430b61c8a48b0e9d81308817c1517"},"breadcrumb":{"@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/#primaryimage","url":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?fit=1024%2C608&ssl=1","contentUrl":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?fit=1024%2C608&ssl=1","width":1024,"height":608},{"@type":"BreadcrumbList","@id":"https:\/\/blexin.com\/en\/blog-en\/creating-angular-components-libraries\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blexin.com\/en\/"},{"@type":"ListItem","position":2,"name":"Creating Angular components libraries"}]},{"@type":"WebSite","@id":"https:\/\/blexin.com\/en\/#website","url":"https:\/\/blexin.com\/en\/","name":"Blexin","description":"Con noi \u00e8 semplice","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blexin.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blexin.com\/en\/#\/schema\/person\/0de430b61c8a48b0e9d81308817c1517","name":"Adolfo Arnold","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ff2a87b54d0f130d7452164533199af05ef16dbd08b9241729946cea0eec7cca?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ff2a87b54d0f130d7452164533199af05ef16dbd08b9241729946cea0eec7cca?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ff2a87b54d0f130d7452164533199af05ef16dbd08b9241729946cea0eec7cca?s=96&d=identicon&r=g","caption":"Adolfo Arnold"},"url":"https:\/\/blexin.com\/en\/author\/adolfo-arnoldblexin-com\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-15.png?fit=1024%2C608&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pcyUBx-7dA","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts\/27750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/users\/196716250"}],"replies":[{"embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/comments?post=27750"}],"version-history":[{"count":6,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts\/27750\/revisions"}],"predecessor-version":[{"id":31952,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts\/27750\/revisions\/31952"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/media\/27729"}],"wp:attachment":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/media?parent=27750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/categories?post=27750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/tags?post=27750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}