Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/piecioshka/ngx-nullish

⚒ Angular Structural Directive which replace `*ngIf` by Nullish Coalescing operator.
https://github.com/piecioshka/ngx-nullish

angular coalescing directive ngif nullish structural

Last synced: 3 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# ngx-nullish

[![node version](https://img.shields.io/node/v/ngx-nullish.svg)](https://www.npmjs.com/package/ngx-nullish)
[![npm version](https://badge.fury.io/js/ngx-nullish.svg)](https://badge.fury.io/js/ngx-nullish)
[![downloads count](https://img.shields.io/npm/dt/ngx-nullish.svg)](https://www.npmjs.com/package/ngx-nullish)
[![size](https://packagephobia.com/badge?p=ngx-nullish)](https://packagephobia.com/result?p=ngx-nullish)
[![license](https://img.shields.io/npm/l/ngx-nullish.svg)](https://piecioshka.mit-license.org)
[![github-ci](https://github.com/piecioshka/ngx-nullish/actions/workflows/testing.yml/badge.svg)](https://github.com/piecioshka/ngx-nullish/actions/workflows/testing.yml)

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

> Give a ⭐️ if this project helped you!

## 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.

## Preview 🎉

## Features

* ✅ Returns **falsy** _only_ for: `null`, `undefined`
* `*ngIf` returns **falsy** for: `null`, `undefined`, `0`, `-0`, `false`, `NaN`, `''`

## Installation

```bash
npm install ngx-nullish
```

## Usage

1. Import deps

```javascript
import { NgxNullishModule } from 'ngx-nullish';

@NgModule({
imports: [
...
NgxNullishModule
],
...
})
export class AppModule { }
```

2. Update template

```html


{{ num }}


```

replace to:

```html


{{ num }}


```

## Deployment

Please run a script:

```bash
./scripts/deploy.sh
```

## License

[The MIT License](https://piecioshka.mit-license.org) @ 2020