ngx-nullish
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

NgxNullish

npm version downloads count github-ci

⚒ Angular Structural Directive which replace *ngIf by Nullish Coalescing operator.

Motivation

Nobody likes "Falsy Values".

When in your stream (RxJS) are numbers (include 0), *ngIf will coerce 0 to false, means UI will not update.

Features

  • ✅ Returns falsy only for null and undefined
    • *ngIf returns falsy for: null, undefined, 0, -0, false, NaN, ''

Installation

npm install ngx-nullish

Usage

  1. Import deps

    import { NgxNullishModule } from 'ngx-nullish';
     
    @NgModule({
    imports: [
        ...
        NgxNullishModule
    ],
    ...
    })
    export class AppModule { }
  2. Update template

    <p *ngIf="numbers$ | async as num">
        {{ num }}
    </p>

    replace to:

    <p *ngxNullish="numbers$ | async as num">
        {{ num }}
    </p>

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

License

The MIT License @ 2020

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i ngx-nullish

    Weekly Downloads

    2

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    90.4 kB

    Total Files

    23

    Last publish

    Collaborators

    • piecioshka