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

1.0.8 • Public • Published

Nopalws

ngx-unless

Angular library which is the opposite to *ngIf, it also preserves the same context

<p *ngxUnless="Conditions.falsy; then thenRef; else elseRef"> Alien exists</p>
 
<!-- assuming -->
<ng-template #thenRef>Templated Alien exists</ng-template>
<ng-template #elseRef>Else Alien DOES NOT exists</ng-template>

Since falsy evaluated condition will be using the thenRef, then you will get

Templated Alien Exists

Please note if we didn't get Alien exits (the text inside the <p> tag is because we added the then context. that means if we don't provide then context like:

<p *ngxUnless="Conditions.falsy"> Alien exists</p>

Then the output will be

Alien exists

Therefore

This Directive is an opposite version of ngIf, code of ngIf directive was taken as base to make this version.

Positive statements enhance readability so instead of doing *ngIf="!isReady" you use *ngxUnless="isReady

Package Sidebar

Install

npm i ngx-unless

Weekly Downloads

8

Version

1.0.8

License

MIT

Unpacked Size

83.7 kB

Total Files

30

Last publish

Collaborators

  • emsedano