All Projects → ng-packagr → Ng Packaged

ng-packagr / Ng Packaged

Licence: mit
An Angular library packaged by ng-packagr

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ng Packaged

Angular2
Angular 2 Seed
Stars: ✭ 75 (-31.19%)
Mutual labels:  angular2, angular4, angular-cli
Angular4 Primeng Admin
angular4-primeng-admin @angular/cli开发的后台模板
Stars: ✭ 99 (-9.17%)
Mutual labels:  angular2, angular4, angular-cli
Angular4-seed
Angular 4 Seed for Angular Forms
Stars: ✭ 37 (-66.06%)
Mutual labels:  angular2, angular4, angular-cli
Angular5 Seed
Angular5 Seed for Application
Stars: ✭ 222 (+103.67%)
Mutual labels:  angular2, angular4, angular-cli
Ngx Smart Modal
Modal/Dialog component crafted for Angular
Stars: ✭ 256 (+134.86%)
Mutual labels:  angular2, angular4, angular-cli
AuthGuard
Example repo for guarding routes post
Stars: ✭ 42 (-61.47%)
Mutual labels:  angular2, angular4, angular-cli
Coreui Free Angular Admin Template
CoreUI Angular is free Angular 2+ admin template based on Bootstrap 4
Stars: ✭ 1,279 (+1073.39%)
Mutual labels:  angular2, angular4, angular-cli
Paper Kit 2 Angular
Free Bootstrap 4 UI Kit for Angular 2+
Stars: ✭ 133 (+22.02%)
Mutual labels:  angular2, angular4, angular-cli
Angular-Movies
Angular Movies | TV Shows is a simple web app that consumes The Movie DB API - Angular 13 + Material Angular
Stars: ✭ 35 (-67.89%)
Mutual labels:  angular2, angular4, angular-cli
ngx-smart-loader
Smart loader handler to manage loaders everywhere in Angular apps.
Stars: ✭ 28 (-74.31%)
Mutual labels:  angular2, angular4, angular-cli
Angular4 Docker Example
Efficiently Dockerized Angular CLI example app
Stars: ✭ 212 (+94.5%)
Mutual labels:  angular2, angular4, angular-cli
Ng Sticky
Angular 4 sticky, have header or any component sticky easy to use.
Stars: ✭ 25 (-77.06%)
Mutual labels:  angular2, angular4, angular-cli
Angular2 Crud Rest
Sample Angular (2.x and 4.x) app: CRUD example + routing
Stars: ✭ 152 (+39.45%)
Mutual labels:  angular2, angular4, angular-cli
laravel5Angular4
Laravel 5.4 & Angular 4.3.4
Stars: ✭ 37 (-66.06%)
Mutual labels:  angular2, angular4, angular-cli
Coreui Free Bootstrap Admin Template
CoreUI is free bootstrap admin template
Stars: ✭ 11,038 (+10026.61%)
Mutual labels:  angular2, angular4, angular-cli
ncg-crud-ngx-md
Angular 4+ Material Design CRUD/Admin app by NinjaCodeGen http://DNAfor.NET
Stars: ✭ 36 (-66.97%)
Mutual labels:  angular2, angular4, angular-cli
ngx-redux-ui-management-recipes
Recipes for managing the UI layout of an application using Redux in Angular
Stars: ✭ 39 (-64.22%)
Mutual labels:  angular2, angular4, angular-cli
Angular Interview Questions
Most extensive Angular interview questions based on your level.
Stars: ✭ 354 (+224.77%)
Mutual labels:  angular2, angular4, angular-cli
Nebular
💥 Customizable Angular UI Library based on Eva Design System 🌚✨Dark Mode
Stars: ✭ 7,368 (+6659.63%)
Mutual labels:  angular2, angular4, angular-cli
Paperadmin
A flat admin dashboard using Angular JS 2/4
Stars: ✭ 80 (-26.61%)
Mutual labels:  angular2, angular4

Packaging Angular libraries with ng-packagr

Renovate enabled CircleCI

Angular libraries are fun!

This repository is an example how to set-up an Angular library project.

It features the @my/lib library package: @my/lib is packaged with ng-packagr and then imported into an Angular CLI app. To run the example, do the following steps:

$ yarn install
$ yarn build:lib
$ ng serve

Here are instructions how this demo was created.

Install

Set up an Angular CLI project, add ng-packagr:

$ ng new ng-packaged
$ yarn add --dev ng-packagr

Create Library

Create a library in my-lib. It's recommended to provide a single public_api.ts as the entry point to your library.

Add Build Script and Configuration

In root package.json:

{
  "name": "ng-packaged",
  "scripts": {
    "build:lib": "ng-packagr"
  }
}

It picks up a configuration in ng-package.json:

{
  "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
  "src": "my-lib",
  "dest": "dist/my-lib",
  "workingDirectory": ".ng_build",
  "lib": {
    "entryFile": "my-lib/src/public_api.ts"
  }
}

ng-packagr comes with built-in support for autoprefixer and postcss. It uses browserslist to determine which browser versions should be supported. Create the file my-lib/.browserslistrc:

last 2 Chrome versions
iOS > 10
Safari > 10

Build

Now, build your library:

$ yarn build:lib

Show off in Demo App

First, in .angular-cli.json set outDir of the Angular CLI app, so that it does not conflict with output directory of your library!

{
  "project": {
    "name": "ng-packaged"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist/app",
      /* ... */
    }
  ]
}

Then, in tsconfig.app.json, map the TypeScript import path:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "paths": {
      "@my/lib": [ "../dist/my-lib" ]
    }
  }
}

Finally, include in your application. In app.module.ts:

import { MyLibModule } from '@my/lib';

@NgModule({
  imports: [
    /* .. */
    MyLibModule.forRoot()
  ],
})
export class AppModule { }

And use them in components like app.component.ts:

import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { BarService } from '@my/lib';

@Component({
  selector: 'app-root',
  template: `
<my-foo></my-foo>
<hr>
<marquee>{{ value$ | async }}</marquee>
`,
  styleUrls: ['./app.component.css']
})
export class AppComponent {

  value$: Observable<string>;

  constructor (
    bar: BarService
  ) {
     this.value$ = bar.value;
  }

}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].