A simple Angular library that contain a huge, useful pack of Directives and Pipes for Angular developers.
- Install
Dipi
library:
$ npm i dipi -D
- Import
DipiModule
inside your Angular module:
....
import { DipiModule } from 'dipi';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
DipiModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Website documentation is in development.
Example
<p>{{ textList | join }}</p> <!-- Dipi,is,working! -->
<p>{{ textList | join: ' ' }}</p> <!-- Dipi is working! -->
Example
Default value: url
. Possible values: 'html' | 'css' | 'js' | 'url' | 'res-url'
<iframe [src]="'https://www.w3schools.com' | safe"></iframe>
<p [style]="'color: red' | safe: 'style'">Red text</p>
Example
textList = [
{
name: 'Dipi',
available: true,
},{
name: 'is',
available: true,
},{
name: 'working!',
available: true,
},{
name: 'Hide me',
available: false
}
]
<p>
<ng-container *ngFor="let node of textList | filter">
<span>{{ node.name }} </span>
</ng-container>
</p>
<p>
<ng-container *ngFor="let node of textList | filter : 'name'">
<span>{{ node.name }} </span>
</ng-container>
</p>
Example
search = 'Dipi';
textList = [
{
name: 'Dipi',
available: true,
},{
name: 'is',
available: true,
},{
name: 'working!',
available: true,
},{
name: 'Hide me',
available: false
}
]
<p>
<ng-container *ngFor="let node of textList | searchFilter: search">
<span>{{ node.name }} </span>
</ng-container>
</p>
Example
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
search = '';
textList = [
{
name: 'Dipi',
available: true,
},{
name: 'is',
available: true,
},{
name: 'working!',
available: true,
},{
name: 'Hide me',
available: false
}
]
filteredList: any[];
constructor() {
this.filteredList = this.textList;
}
filterSearch(): void {
this.filteredList = this.textList.filter((e: any) => e.name.includes(this.search));
}
}
<h2>Dipi Seed</h2>
<input type="search"
[debounce]
[(ngModel)]="search"
(debouceEvent)="filterSearch()">
<p>
<ng-container *ngFor="let node of filteredList">
<span>
{{ node.name }}
</span>
</ng-container>
</p>
<h2>Dipi Seed</h2>
<input type="search"
[debounce]="2000"
[(ngModel)]="search"
(debouceEvent)="filterSearch()">
<p>
<ng-container *ngFor="let node of filteredList">
<span>
{{ node.name }}
</span>
</ng-container>
</p>
Example
List of items
textList = [
{
name: 'Dipi',
available: true,
},{
name: 'is',
available: true,
},{
name: 'working!',
available: true,
},{
name: 'Hide me',
available: false
},{
name: 'Foo',
available: false
},{
name: 'Bar',
available: false
},{
name: 'Buz',
available: false
}
]
Component css
ul {
height: 100px;
overflow-y: auto;
}
ul li {
min-height: 35px;
}
Directive usage
<ul>
<li *lazyFor="let k of textList">
{{ k.name }}
</li>
</ul>
-
Pipes:
| distinct
| formatter
| timer
-
Directives:
-
Website documentation
I will be so glad if you will create an issue with your own useful Directive
or Pipe
that will be used by other Angular developers .
Knowledge sharing is our strength!
Please read contributing guidelines here.
MIT