2.0.1 • Published 3 months ago

ngx-if-platform v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

npm version Package License NPM Downloads Snyk codecov stars forks HitCount

Angular directive for conditional display based on platform

Angular 17 compatible

Here's the demo or stackblitz live preview or codesandbox live preview

  • Lightweight
  • No dependencies!
  • Directive way

Install

  1. Use yarn (or npm) to install the package
yarn add ngx-if-platform
  1. Add NgxIfPlatformModule (or specific directive) into your imports
import { NgxIfPlatformModule } from 'ngx-if-platform';

@Component({
  standalone: true,
  imports: [NgxIfPlatformModule /* , ... */],
  // ...
})

or

  import { NgxIfPlatformModule } from 'ngx-if-platform';

  @NgModule({
   // ...
   imports: [
     // ...
     NgxIfPlatformModule
   ]
  })

Compatibility

Angularngx-if-platformInstall
>= 142.xyarn add ngx-if-platform
>= 121.xyarn add ngx-if-platform@1
>= 5 < 130.xyarn add ngx-if-platform@0

Quick start

Example code

<!-- ngxIf -->
<div *ngxIfBrowser>Is browser</div>
<!-- ngxIf can be disabled  -->
<ng-template [ngxIfServer]="true">Is server (disabled)</ng-template>
<!-- ngxIf else statement  -->
<ng-template [ngxIfServer] [ngxIfNotServer]="notServer">Is server</ng-template>
<ng-template #notServer>Not server</ng-template>

Result

  Is browser
  Is server (disabled)
  Not server

Options

There are these directives: ngxIfBrowser, ngxIfServer, ngxIfWorkerApp, ngxIfWorkerUi

Directive & attributes

OptionTypeDefaultDescription
ngxIfBrowserbooleantrueDirective can be disabled
ngxIfNotBrowsertemplateRefnoneTemplateRef used if confition do not match
ngxIfServerbooleantrueDirective can be disabled
ngxIfNotServertemplateRefnoneTemplateRef used if confition do not match
ngxIfWorkerAppbooleantrueDirective can be disabled
ngxIfNotWorkerApptemplateRefnoneTemplateRef used if confition do not match
ngxIfWorkerUibooleantrueDirective can be disabled
ngxIfNotWorkerUitemplateRefnoneTemplateRef used if confition do not match

Dependencies

None

License

Copyright © 2021 - 2024 Dominik Hladik

All contents are licensed under the MIT license.

2.0.1

3 months ago

2.0.0

5 months ago

1.1.0

9 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.4

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago