npm.io
1.7.33 • Published 5 years ago

ii-ngx-common

Licence
—
Version
1.7.33
Deps
1
Size
85 kB
Vulns
0
Weekly
0

NgxCommon

Angular 2+ common components, pipes, services, directives

Installation

  1. Use npm to install the package
$ npm install ii-ngx-common --save
  1. You could either add into your module imports the NgxCommonModule in order to add all of the pipes
import { NgxCommonModule } from "ii-ngx-common";

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

Safe pipe

Marks value that's safe to use as HTML, CSS, Script, etc.........

Usage
<div [innerHTML]="data | safe:'html'">Safe html</div>
<div [innerHTML]="data | safe:'style'">Safe css</div>
<div [innerHTML]="data | safe:'script'">Safe css</div>
<div [innerHTML]="data | safe:'url'">Safe css</div>
<div [innerHTML]="data | safe:'resourceUrl'">Safe css</div>

Unsubscribe service

Observable service which is unsubscribed after service is destroyed.

Usage
import {UnsubscribeService} from "ii-ngx-common";

@Component({
  ...
  providers: [UnsubscribeService]
})
export class MyComponent {
  constructor(unsubscribeService$: UnsubscribeService) {
    someObservable.pipe(
	  takeUntil(unsubscribeService$)
	).subscribe(() => {
	  ...
	});
  }
}