Top
In theme we are using Abstract Elements for calling small widgets. so It will easy to use and user freindlly from developer perspective.
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-light">Light</button>
<button type="button" class="btn btn-dark">Dark</button>
<button type="button" class="btn btn-link">Link</button>
To use another types button you have to link the related css file according to types of buttons in a head tag
<span class="badge badge-primary">Primary</span>
<span class="badge badge-secondary">Secondary</span>
<span class="badge badge-success">Success</span>
<span class="badge badge-info">Info</span>
<span class="badge badge-warning text-dark">Warning</span>
<span class="badge badge-danger">Danger</span>
<span class="badge badge-light text-dark">Light</span>
<span class="badge badge-dark tag-pills-sm-mb">Dark</span>
<ngb-progressbar class="mb-3" type="success" [value]="25" />
<ngb-progressbar class="mb-3" type="info" [value]="50" />
<ngb-progressbar class="mb-3" type="warning" [value]="75" />
<ngb-progressbar class="mb-3" type="danger" [value]="100" />
<ngb-progressbar class="mb-3" type="primary" [value]="75" />
<ngb-progressbar class="mb-3" type="secondary" [value]="50" />
<ngb-progressbar class="mb-3" type="dark" [value]="25" />
import { Component } from '@angular/core';
import { NgbProgressbarModule } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'ngbd-progressbar-basic',
imports: [NgbProgressbarModule],
templateUrl: './progressbar-basic.html',
})
export class NgbdProgressbarBasic {}
@for (alert of alerts; track alert) {
<ngb-alert [type]="alert.type" (closed)="close(alert)">{{ alert.message }}</ngb-alert>
}
import { Component } from '@angular/core';
import { NgbAlertModule } from '@ng-bootstrap/ng-bootstrap';
interface Alert {
type: string;
message: string;
}
const ALERTS: Alert[] = [
{
type: 'success',
message: 'This is an success alert',
},
{
type: 'info',
message: 'This is an info alert',
},
{
type: 'warning',
message: 'This is a warning alert',
},
{
type: 'danger',
message: 'This is a danger alert',
},
{
type: 'primary',
message: 'This is a primary alert',
},
{
type: 'secondary',
message: 'This is a secondary alert',
},
{
type: 'light',
message: 'This is a light alert',
},
{
type: 'dark',
message: 'This is a dark alert',
},
];
@Component({
selector: 'ngbd-alert-closeable',
imports: [NgbAlertModule],
templateUrl: './alert-closeable.html',
})
export class NgbdAlertCloseable {
alerts: Alert[];
close(alert: Alert) {
this.alerts.splice(this.alerts.indexOf(alert), 1);
}
}
<button
type="button"
class="btn btn-outline-secondary me-2"
placement="top"
ngbPopover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
popoverTitle="Popover on top">
Popover on top
</button>
// ts file
import { Component } from '@angular/core';
import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'ngbd-popover-basic',
imports: [NgbPopoverModule],
templateUrl: './popover-basic.html',
host: { class: 'd-block' },
})
export class NgbdPopoverBasic {}
// tooltip.html //
<button class="example-popover btn btn-primary" type="button" placement="top" title="Popover title"
ngbTooltip="Basic Tooltip">Hover
Me</button>
import { Component } from '@angular/core';
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-tooltip',
templateUrl: './tooltip.html',
styleUrls: ['./tooltip.scss'],
imports: [NgbTooltip]
})
export class Tooltip {
}
Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
<ul ngbNav #nav="ngbNav" [activeId]="2" class="nav-tabs justify-content-center">
<li [ngbNavItem]="1">
<a ngbNavLink>Simple</a>
<ng-template ngbNavContent>
<p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth
master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro
keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat
salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
</ng-template>
</li>
<li [ngbNavItem]="2">
<a ngbNavLink><b>Fancy</b> title</a>
<ng-template ngbNavContent>
<p>Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko
farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts
ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar
helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson
8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester
stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.</p>
</ng-template>
</li>
<li ngbDropdown class="nav-item">
<a href (click)="false" class="nav-link" ngbDropdownToggle>Dropdown</a>
<div ngbDropdownMenu>
<button ngbDropdownItem>Action</button>
<button ngbDropdownItem>Another action</button>
<button ngbDropdownItem>Something else here</button>
<div class="dropdown-divider"></div>
<button ngbDropdownItem>Separated link</button>
</div>
</li>
<li ngbNavItem [disabled]="true" class="ms-auto">
<a ngbNavLink>Disabled</a>
<ng-template ngbNavContent>
<p>Sed commodo, leo at suscipit dictum, quam est porttitor sapien, eget sodales nibh elit id diam. Nulla facilisi.
Donec egestas ligula vitae odio interdum aliquet. Duis lectus turpis, luctus eget tincidunt eu, congue et odio.
Duis pharetra et nisl at faucibus. Quisque luctus pulvinar arcu, et molestie lectus ultrices et. Sed diam urna,
egestas ut ipsum vel, volutpat volutpat neque. Praesent fringilla tortor arcu. Vivamus faucibus nisl enim, nec
tristique ipsum euismod facilisis. Morbi ut bibendum est, eu tincidunt odio. Orci varius natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus. Mauris aliquet odio ac lorem aliquet ultricies in eget
neque. Phasellus nec tortor vel tellus pulvinar feugiat.</p>
</ng-template>
</li>
</ul>
<div [ngbNavOutlet]="nav" class="mt-2"></div>
<ngb-accordion [closeOthers]="true" activeIds="static-1">
<ngb-panel id="static-1" title="Simple">
<ng-template ngbPanelContent>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia
aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor,
sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica,
craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings
occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus
labore sustainable VHS.
</ng-template>
</ngb-panel>
<ngb-panel id="static-2">
<ng-template ngbPanelTitle>
<span>★ <b>Fancy</b> title ★</span>
</ng-template>
<ng-template ngbPanelContent>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia
aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor,
sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica,
craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings
occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus
labore sustainable VHS.
</ng-template>
</ngb-panel>
<ngb-panel id="static-3" title="Disabled" [disabled]="true">
<ng-template ngbPanelContent>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia
aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor,
sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica,
craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings
occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus
labore sustainable VHS.
</ng-template>
</ngb-panel>
</ngb-accordion>
Installing and usage
npm i ngx-toastr
// toster.html
<button class="btn btn-primary" type="button" id="liveToastBtn" (click)="showSuccess()">
Show live toast
</button>
// toster.ts
export class Toaster {
constructor(private toastr: ToastrService) {}
showSuccess() {
this.toastr.success("everything is broken", "Major Error", {
timeOut: 3000,
});
}
}
// app.config.ts
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideRouter } from '@angular/router';
import { provideToastr } from 'ngx-toastr';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideToastr(),
provideAnimations(),
]
};
Installing and usage
Installing and usage
npm i @sweetalert2
// sweetalert2.html
<button class="btn btn-primary sweet-1" type="button" (click)="basicAlert()">Basic</button>
import { Component } from '@angular/core';
import Swal from 'sweetalert2';
@Component({
selector: 'app-sweetalert2',
templateUrl: './sweetalert2.html',
styleUrls: ['./sweetalert2.scss'],
})
export class Sweetalert2{
basicAlert() {
Swal.fire('Hello world!')
}
}
Installing and usage
npm i @angular-slider/ngx-slider
// range-slider.html //
<ngx-slider [(value)]="value" [options]="options"></ngx-slider>
// range-sliders.ts //
import { Component} from '@angular/core';
import { Options, NgxSliderModule } from '@angular-slider/ngx-slider';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-range-slider',
templateUrl: './range-slider.html',
styleUrls: ['./range-slider.scss'],
imports: [FormsModule, NgxSliderModule]
})
export class RangeSlider{
value: number = 100;
options: Options = {
floor: 0,
ceil: 200
};
}
Installing and usage
npm i ngx-dropzone
// dropzone.html
<dropzone [config]="default" [classList]="'custom-dropzone'" [message]="textDefault" ></dropzone>
// dropzone.ts
import { Component, SimpleChange } from '@angular/core';
import { DropzoneConfigInterface, DropzoneModule } from 'ngx-dropzone-wrapper';
@Component({
selector: 'app-dropzone',
templateUrl: './dropzone.html',
styleUrls: ['./dropzone.scss'],
imports: [ DropzoneModule],
})
export class Dropzone {
public default: DropzoneConfigInterface = {
clickable: true,
url: 'https://httpbin.org/post',
acceptedFiles: 'image/*',
addRemoveLinks: true,
uploadMultiple: true,
parallelUploads: 1,
};
}
Installing and usage
npm i @danielmoncada/angular-datetime-picker
//datetimepicker.html //
<input class="datepicker-here form-control digits" placeholder="yyyy-mm-dd" name="dp"
[(ngModel)]="model" ngbDatepicker #d="ngbDatepicker" (click)="d.toggle()" />
//datetimepicker.ts //
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NgbDateStruct, NgbInputDatepicker } from '@ng-bootstrap/ng-bootstrap';
import { FeatherIcons } from '../../../../shared/components/feather-icons/feather-icons';
@Component({
selector: 'app-datepicker',
templateUrl: './datepicker.html',
styleUrls: ['./datepicker.scss'],
imports: [FormsModule, NgbInputDatepicker, FeatherIcons]
})
export class Datepicker {
model: NgbDateStruct;
}
Installing and usage
npm i @ng-bootstrap/ng-bootstrap
<label for="typeahead-basic">Search for a state:</label>
<input id="typeahead-basic" type="text" class="form-control" [(ngModel)]="model" [ngbTypeahead]="search" />
// ts files
import { Component } from '@angular/core';
import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
import { Observable, OperatorFunction } from 'rxjs';
import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
import { FormsModule } from '@angular/forms';
import { JsonPipe } from '@angular/common';
const states = [
'Alabama',
'Alaska',
'American Samoa',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'District Of Columbia',
'Federated States Of Micronesia',
'Florida',
'Georgia',
'Guam',
'Hawaii',
'Idaho',
'Illinois',
'Indiana',
'Iowa',
'Kansas',
'Kentucky',
'Louisiana',
'Maine',
'Marshall Islands',
'Maryland',
'Massachusetts',
'Michigan',
'Minnesota',
'Mississippi',
'Missouri',
'Montana',
'Nebraska',
'Nevada',
'New Hampshire',
'New Jersey',
'New Mexico',
'New York',
'North Carolina',
'North Dakota',
'Northern Mariana Islands',
'Ohio',
'Oklahoma',
'Oregon',
'Palau',
'Pennsylvania',
'Puerto Rico',
'Rhode Island',
'South Carolina',
'South Dakota',
'Tennessee',
'Texas',
'Utah',
'Vermont',
'Virgin Islands',
'Virginia',
'Washington',
'West Virginia',
'Wisconsin',
'Wyoming',
];
@Component({
selector: 'ngbd-typeahead-basic',
imports: [NgbTypeaheadModule, FormsModule, JsonPipe],
templateUrl: './typeahead-basic.html',
styles: `.form-control { width: 300px; }`,
})
export class NgbdTypeaheadBasic {
model: any;
search: OperatorFunction = (text$: Observable) =>
text$.pipe(
debounceTime(200),
distinctUntilChanged(),
map((term) =>
term.length < 2 ? [] : states.filter((v) => v.toLowerCase().indexOf(term.toLowerCase()) > -1).slice(0, 10),
),
);
}
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Installing and usage
npm i bootstrap
<table class="table">
<thead>
<tr>
<th scope="col"># </th>
<th scope="col">First </th>
<th scope="col">Last </th>
<th scope="col">Handle </th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1 </th>
<td>Mark </td>
<td>Otto </td>
<td>@mdo </td>
</tr>
<tr>
<th scope="row">2 </th>
<td>Jacob </td>
<td>Thornton </td>
<td>@fat </td>
</tr>
<tr>
<th scope="row">3 </th>
<td colspan="2">Larry the Bird </td>
<td>@twitter </td>
</tr>
</tbody>
</table>
Installing and usage
npm i @ng-bootstrap/ng-bootstrap
// table.html
<form>
<div class="mb-3 row">
<label for="table-complete-search" class="col-xs-3 col-sm-auto col-form-label">Full text search:</label>
<div class="col-xs-3 col-sm-auto">
<input
id="table-complete-search"
type="text"
class="form-control"
name="searchTerm"
[(ngModel)]="service.searchTerm"
/>
</div>
@if (service.loading$ | async) {
<span class="col col-form-label">Loading...</span>
}
</div>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col" sortable="name" (sort)="onSort($event)">Country</th>
<th scope="col" sortable="area" (sort)="onSort($event)">Area</th>
<th scope="col" sortable="population" (sort)="onSort($event)">Population</th>
</tr>
</thead>
<tbody>
@for (country of countries$ | async; track country.id) {
<tr>
<th scope="row">{{ country.id }}</th>
<td>
<img
[src]="'https://upload.wikimedia.org/wikipedia/commons/' + country.flag"
[alt]="'The flag of ' + country.name"
class="me-2"
style="width: 20px"
/>
<ngb-highlight [result]="country.name" [term]="service.searchTerm" />
</td>
<td><ngb-highlight [result]="country.area | number" [term]="service.searchTerm" /></td>
<td><ngb-highlight [result]="country.population | number" [term]="service.searchTerm" /></td>
</tr>
} @empty {
<tr>
<td colspan="4" style="text-align: center">No countries found</td>
</tr>
}
</tbody>
</table>
<div class="d-flex justify-content-between p-2">
<ngb-pagination [collectionSize]="(total$ | async)!" [(page)]="service.page" [pageSize]="service.pageSize">
</ngb-pagination>
<select class="form-select" style="width: auto" name="pageSize" [(ngModel)]="service.pageSize">
<option [ngValue]="2">2 items per page</option>
<option [ngValue]="4">4 items per page</option>
<option [ngValue]="6">6 items per page</option>
</select>
</div>
</form>
// table.ts
import { AsyncPipe, DecimalPipe } from '@angular/common';
import { Component, inject, viewChildren } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NgbHighlight, NgbPagination } from '@ng-bootstrap/ng-bootstrap';
import { Observable } from 'rxjs';
import {
NgbdSortableHeaderDirective,
SortEvent,
} from '../../../shared/directives/sortable.directive';
import { Table } from '../../../shared/interface/table';
import { TableService } from '../../../shared/services/tables/tables.service';
@Component({
selector: 'app-data-table',
templateUrl: './data-table.html',
styleUrls: ['./data-table.scss'],
providers: [TableService, DecimalPipe],
imports: [FormsModule, NgbdSortableHeaderDirective, NgbHighlight, NgbPagination, AsyncPipe],
})
export class DataTable {
service = inject(TableService);
basicTable$: Observable;
total$: Observable;
readonly headers = viewChildren(NgbdSortableHeaderDirective);
constructor() {
const service = this.service;
this.basicTable$ = service.basicTable$;
this.total$ = service.total$;
}
onSort({ column, direction }: SortEvent) {
this.headers().forEach(header => {
if (header.sortable() !== column) {
header.currentDirection.set('');
}
});
this.service.sortColumn = column;
this.service.sortDirection = direction;
}
}
// table service
import { DecimalPipe } from '@angular/common';
import { Injectable, PipeTransform, inject } from '@angular/core';
import {
BehaviorSubject,
of,
Observable,
Subject,
tap,
debounceTime,
switchMap,
delay,
} from 'rxjs';
import { TABLEDATA } from '../../data/table/tableData';
import { SortColumn, SortDirection } from '../../directives/sortable.directive';
import { Table } from '../../interface/table';
interface SearchResult {
basicTable: Table[];
total: number;
}
interface State {
page: number;
pageSize: number;
searchTerm: string;
sortColumn: SortColumn;
sortDirection: SortDirection;
}
const compare = (v1: string | number, v2: string | number) => (v1 < v2 ? -1 : v1 > v2 ? 1 : 0);
function sort(basicTable: Table[], column: SortColumn, direction: string): Table[] {
if (direction === '' || column === '') {
return basicTable;
} else {
return [...basicTable].sort((a, b) => {
const res = compare(a[column], b[column]);
return direction === 'asc' ? res : -res;
});
}
}
function matches(table: Table, term: string, pipe: PipeTransform) {
return (
table.name.toLowerCase().includes(term.toLowerCase()) ||
pipe.transform(table.invoice).includes(term) ||
table.office.toLowerCase().includes(term.toLowerCase())
);
}
@Injectable({
providedIn: 'root',
})
export class TableService {
private pipe = inject(DecimalPipe);
private _loading$ = new BehaviorSubject(true);
private _search$ = new Subject();
private _tables$ = new BehaviorSubject([]);
private _total$ = new BehaviorSubject(0);
private _state: State = {
page: 1,
pageSize: 4,
searchTerm: '',
sortColumn: '',
sortDirection: '',
};
constructor() {
this._search$
.pipe(
tap(() => this._loading$.next(true)),
debounceTime(200),
switchMap(() => this._search()),
delay(200),
tap(() => this._loading$.next(false)),
)
.subscribe(result => {
this._tables$.next(result.basicTable);
this._total$.next(result.total);
});
this._search$.next();
console;
}
get basicTable$() {
return this._tables$.asObservable();
}
get total$() {
return this._total$.asObservable();
}
get loading$() {
return this._loading$.asObservable();
}
get page() {
return this._state.page;
}
get pageSize() {
return this._state.pageSize;
}
get searchTerm() {
return this._state.searchTerm;
}
set page(page: number) {
this._set({ page });
}
set pageSize(pageSize: number) {
this._set({ pageSize });
}
set searchTerm(searchTerm: string) {
this._set({ searchTerm });
}
set sortColumn(sortColumn: SortColumn) {
this._set({ sortColumn });
}
set sortDirection(sortDirection: SortDirection) {
this._set({ sortDirection });
}
private _set(patch: Partial) {
Object.assign(this._state, patch);
this._search$.next();
}
private _search(): Observable {
const { sortColumn, sortDirection, pageSize, page, searchTerm } = this._state;
// 1. sort
let basicTable = sort(TABLEDATA, sortColumn, sortDirection);
// 2. filter
basicTable = basicTable.filter(country => matches(country, searchTerm, this.pipe));
const total = basicTable.length;
// 3. paginate
basicTable = basicTable.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize);
return of({ basicTable, total });
}
}
// directives
import { Directive, HostBinding, HostListener, input, output, signal } from '@angular/core';
import { Table } from '../interface/table';
export type SortColumn = keyof Table | '';
export type SortDirection = 'asc' | 'desc' | '';
const rotate: { [key: string]: SortDirection } = { asc: 'desc', desc: '', '': 'asc' };
export interface SortEvent {
column: SortColumn;
direction: SortDirection;
}
@Directive({
selector: 'th[sortable]',
host: {
'[class.asc]': 'direction === "asc"',
'[class.desc]': 'direction === "desc"',
'(click)': 'rotate()',
},
})
export class NgbdSortableHeaderDirective {
readonly sortable = input('');
readonly direction = input(''); // initial direction from parent
public currentDirection = signal(this.direction());
readonly sort = output();
@HostBinding('class.asc')
get isAsc() {
return this.currentDirection() === 'asc';
}
@HostBinding('class.desc')
get isDesc() {
return this.currentDirection() === 'desc';
}
// HostListener to handle clicks
@HostListener('click')
rotateColumn() {
this.currentDirection.set(rotate[this.currentDirection()]);
this.sort.emit({ column: this.sortable(), direction: this.currentDirection() });
}
}
// data
export interface Table {
id: number;
img: string;
name: string;
position: string;
office: string;
credit: string;
invoice: string;
startDate: string;
salary: string;
Budget: string;
ActionClass: string;
iconClass: string;
iconColor: string;
}
export const TABLEDATA: Table[] = [
{
id: 1,
img: 'assets/images/user/1.jpg',
name: 'Tiger Nixon',
position: 'System Architect',
office: 'Hewlett packard',
invoice: '#PX0101',
startDate: '2022/04/27',
Budget: '$3142.00',
salary: 'High',
credit: '4.3%',
ActionClass: 'badge-light-primary',
iconClass: 'icofont-arrow-up',
iconColor: 'success',
},
{
id: 2,
img: 'assets/images/user/2.jpg',
name: 'Garrett Winters',
position: 'Maintenace service',
office: 'Apple Inc.',
invoice: '#RF304f',
startDate: '2022/04/22',
Budget: '$1234.00',
salary: 'Urgent',
credit: '5.6%',
ActionClass: 'badge-light-danger',
iconClass: 'icofont-arrow-up',
iconColor: 'success',
},
{
id: 3,
img: 'assets/images/user/3.jpg',
name: 'Ashton Cox',
position: 'Junior Technical Author ',
office: 'Edinburgh',
invoice: '#DNJ480',
startDate: '2022/05/21',
Budget: '$2345.00',
salary: 'Low',
credit: '2.4%',
ActionClass: 'badge-light-success',
iconClass: 'icofont-arrow-down',
iconColor: 'danger',
},
{
id: 4,
img: 'assets/images/user/6.jpg',
name: 'Brielle Williams',
position: 'Senior Javascript Developer',
office: 'Microsoft',
invoice: '#G189d0',
startDate: '2022/03/09',
Budget: '$7689.00',
salary: 'Medium',
credit: '2.2%',
ActionClass: 'badge-light-warning',
iconClass: 'icofont-arrow-down',
iconColor: 'danger',
},
{
id: 5,
img: 'assets/images/user/7.jpg',
name: 'Tiger Nixon',
position: 'Accountant',
office: 'Tata Co.',
invoice: '#31D8FFS',
startDate: '2022/04/10',
Budget: '$2145.00',
salary: 'High',
credit: '5.8%',
ActionClass: 'badge-light-primary',
iconClass: 'icofont-arrow-up',
iconColor: 'success',
},
{
id: 6,
img: 'assets/images/user/14.png',
name: 'Michael Morris',
position: 'General service',
office: 'Google Inc.',
invoice: '#G189D4',
startDate: '2022/06/12',
Budget: '$2578.00',
salary: 'Urgent',
credit: '6.4%',
ActionClass: 'badge-light-danger',
iconClass: 'icofont-arrow-up',
iconColor: 'success',
},
{
id: 7,
img: 'assets/images/user/10.jpg',
name: 'Kevin Dawson',
position: 'System Architect',
office: 'Mindtree Ltd.',
invoice: '#PX2101',
startDate: '2022/04/25',
Budget: '$6538.00',
salary: 'Low',
credit: '0.3%',
ActionClass: 'badge-light-sucess',
iconClass: 'icofont-arrow-down',
iconColor: 'danger',
},
{
id: 8,
img: 'assets/images/user/12.png',
name: 'Thomas Taylor',
position: 'System Architect',
office: 'Wipro Ltd.',
invoice: '#px0101',
startDate: '2022/06/09',
Budget: '$2121.00',
salary: 'Urgent',
credit: '7.3%',
ActionClass: 'badge-light-danger',
iconClass: 'icofont-arrow-up',
iconColor: 'success',
},
{
id: 9,
img: 'assets/images/user/14.png',
name: 'Carolyn Jones',
position: 'General service',
office: 'Edinburgh',
invoice: '#G5384H',
startDate: '2022/01/11',
Budget: '$9546.00',
salary: 'High',
credit: '6.3%',
ActionClass: 'badge-light-primary',
iconClass: 'icofont-arrow-up',
iconColor: 'success',
},
{
id: 10,
img: 'assets/images/user/6.jpg',
name: 'Glen Matney',
position: 'System Architect',
office: 'Mphasis Ltd',
invoice: '#E5384H',
startDate: '2022/04/02',
Budget: '$4587.00',
salary: 'Medium',
credit: '3.3%',
ActionClass: 'badge-light-warning',
iconClass: 'icofont-arrow-down',
iconColor: 'danger',
},
{
id: 11,
img: 'assets/images/user/9.jpg',
name: 'Charles Kubik',
position: 'System Architect',
office: 'Infosys Ltd.',
invoice: '#JK384H',
startDate: '2022/05/01',
Budget: '$3140.00',
salary: 'Low',
credit: '2.3%',
ActionClass: 'badge-light-success',
iconClass: 'icofont-arrow-down',
iconColor: 'danger',
},
{
id: 12,
img: 'assets/images/user/10.jpg',
name: 'Herbert Stokes',
position: 'General service',
office: 'Edinburgh',
invoice: '#HY5384H',
startDate: '2022/07/04',
Budget: '$3014.00',
salary: 'Low',
credit: '1.3%',
ActionClass: 'badge-light-success',
iconClass: 'icofont-arrow-down',
iconColor: 'danger',
},
{
id: 13,
img: 'assets/images/user/11.png',
name: 'Mary Cousar',
position: 'System Architect',
office: 'Infosys.',
invoice: '#KH384H',
startDate: '2022/04/06',
Budget: '$2014.00',
salary: 'Urgent',
credit: '5.3%',
ActionClass: 'badge-light-danger',
iconClass: 'icofont-arrow-up',
iconColor: 'success',
},
];
Supplemental
Charts
Installing and usage
npm i ng-apexcharts
// apex-chartss.html //
<apx-chart
[chart]="turnover.chart"
[series]="turnover.series"
[colors]="turnover.colors"
[dataLabels]="turnover.dataLabels"
[xaxis]="turnover.xaxis"
[yaxis]="turnover.yaxis"
[stroke]="turnover.stroke"
[labels]="turnover.labels"
[legend]="turnover.legend">
</apx-chart>
// apex-chart.ts //
import { Component } from '@angular/core';
import * as chartData from '../../../../shared/data/charts/apex'
import { NgApexchartsModule } from 'ng-apexcharts';
@Component({
selector: 'app-basic-area-chart',
templateUrl: './basic-area-chart.html',
styleUrls: ['./basic-area-chart.scss'],
imports: [NgApexchartsModule]
})
export class BasicAreaChart {
public turnover = chartData.splineArea1
}
// apex-chart-data.ts //
import {BasicChart} from '../../interface/charts/apex-charts';
let primary_color = localStorage.getItem('primary_color') || '#2B5F60';
let secondary_color = localStorage.getItem('secondary_color') || '#C06240';
export let splineArea1 :BasicChart = {
series: [
{
name: "STOCK ABC",
data: [8107.85, 8128.0, 8122.9, 8165.5, 8340.7, 8423.7, 8423.5, 8514.3, 8481.85, 8487.7, 8506.9, 8626.2, 8668.95, 8602.3, 8607.55, 8512.9, 8496.25, 8600.65, 8881.1, 9340.85],
}
],
colors: [primary_color],
chart: {
type: "area",
height: 350,
toolbar: {
show: false
},
zoom: {
enabled: false
}
},
dataLabels: {
enabled: false
},
stroke: {
curve: "straight"
},
labels: ["13 Nov 2017", "14 Nov 2017", "15 Nov 2017", "16 Nov 2017", "17 Nov 2017", "20 Nov 2017", "21 Nov 2017", "22 Nov 2017", "23 Nov 2017", "24 Nov 2017", "27 Nov 2017", "28 Nov 2017", "29 Nov 2017", "30 Nov 2017", "01 Dec 2017", "04 Dec 2017", "05 Dec 2017", "06 Dec 2017", "07 Dec 2017", "08 Dec 2017"
],
xaxis: {
type: "datetime"
},
yaxis: {
opposite: true
},
legend: {
horizontalAlign: "left"
}
};
Supplemental
Installing and usage
npm i ng2-google-charts
// google-chart.html //
<google-chart [data]="pieChart1"></google-chart>
// google-chart.ts //
import { Component } from '@angular/core';
import * as chartData from '../../../shared/data/chart/google-chart';
import { Ng2GoogleChartsModule } from 'ng2-google-charts';
@Component({
selector: 'app-google',
templateUrl: './google.html',
styleUrls: ['./google.scss'],
standalone: true,
imports: [Ng2GoogleChartsModule]
})
export class Google {
constructor() { }
// Pie Chart
public pieChart1 = chartData.pieChart1
}
// google-chart-data.ts //
let primary_color = localStorage.getItem('primary_color') || '#7e37d8';
let secondary_color = localStorage.getItem('secondary_color') || '#fe80b2';
// Pie Chart 1
export var pieChart1 = {
chartType: 'PieChart'
dataTable: [
['Task', 'Hours per Day'],
['Work', 5],
['Eat', 10],
['Commute', 15],
['Watch TV', 20],
['Sleep', 25]
],
options: {
title: 'My Daily Activities',
width: '100%',
height: 400,
colors: ["#06b5dd", primary_color, secondary_color, "#80cf00", "#FF5370"],
backgroundColor: 'transparent'
},
};
Supplemental
Installing and usage
npm i ng2-charts
//chartjs.html//
<canvas baseChart class="chart"
baseChart
class="chart"
[data]="barChart"
[datasets]="barChart.datasets"
[options]="barChart.barOptions"
">
</canvas>
//chartjs.ts//
import { Component } from '@angular/core';
import { BarController, BarElement, CategoryScale, LinearScale } from 'chart.js';
import { BaseChartDirective, provideCharts } from 'ng2-charts';
import { barChart } from '../../../../shared/data/charts/chartsjs';
@Component({
selector: 'app-bars-chart',
templateUrl: './bars-chart.html',
styleUrls: ['./bars-chart.scss'],
imports: [BaseChartDirective],
providers: [
provideCharts({
registerables: [BarController, CategoryScale, LinearScale, BarElement],
}),
],
})
export class BarsChart {
public barChart = barChart;
}
// chartjs-data.ts //
;
import { ChartDataset, ChartOptions, ChartType } from 'chart.js';
let primary_color = localStorage.getItem('primary_color') || 'var(--theme-default)';
let secondary_color = localStorage.getItem('secondary_color') || 'var(--theme-secondary)';
let primary_color = '#2B5F60';
let secondary_color = '#C06240';
export const barChart = {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
responsive: false,
datasets: [
{
label: 'My First dataset',
backgroundColor: 'rgba(43, 94, 94, 0.4)',
borderColor: primary_color,
borderWidth: 2,
data: [35, 59, 80, 81, 56, 55, 40],
},
{
label: 'My Second dataset',
borderColor: secondary_color,
backgroundColor: 'rgba(192, 98, 64, 0.4)',
borderWidth: 2,
data: [28, 48, 40, 19, 86, 27, 90],
},
],
barOptions: [
{
scaleBeginAtZero: true,
scaleShowGridLines: true,
scaleGridLineColor: 'rgba(0,0,0,0.1)',
scaleGridLineWidth: 1,
scaleShowHorizontalLines: true,
scaleShowVerticalLines: true,
barShowStroke: true,
barStrokeWidth: 2,
barValueSpacing: 5,
barDatasetSpacing: 1,
},
],
};
app.config.ts
import { HttpClient } from '@angular/common/http';
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideRouter } from '@angular/router';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { provideCharts, withDefaultRegisterables } from 'ng2-charts';
import { routes } from './app.routes';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideAnimations(),
provideCharts(withDefaultRegisterables()),
]
};
Supplemental
Installing and usage
npm i ng-chartist
// chartist.html
<x-chartist [configuration]="chart1" ></x-chartist>
// chartist.html
import { Component } from '@angular/core';
import * as chartData from '../../../../shared/data/charts/chartist';
import { ChartistModule } from 'ng-chartist';
@Component({
selector: 'app-advanced-smil',
templateUrl: './advanced-smil.html',
styleUrls: ['./advanced-smil.scss'],
imports: [ChartistModule]
})
export class AdvancedSmil {
public chart1 = chartData.chart1;
}
// chartist-data.ts
import * as Chartist from 'chartist';
import { BarChartConfiguration, LineChartConfiguration, PieChartConfiguration } from 'ng-chartist
let primary_color = localStorage.getItem('primary_color') || '#2B5F60';
let secondary_color = localStorage.getItem('secondary_color') || '#C06240';
export var chart1: LineChartConfiguration = {
type: 'Line',
data: {
labels: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
series: [
[12, 9, 7, 8, 5, 4, 6, 2, 3, 3, 4, 6],
[4, 5, 3, 7, 3, 5, 5, 3, 4, 4, 5, 5],
[5, 3, 4, 5, 6, 3, 3, 4, 5, 6, 3, 4],
[3, 4, 5, 6, 7, 6, 4, 5, 6, 7, 6, 3],
],
},
options: {
low: 0,
showArea: false,
fullWidth: true,
height: 250,
},
};
Supplemental
Maps
Installing and usage
npm i @angular/google-maps
// google-map.html
<google-map width="100%" height="500px" [zoom]="zoom">
@for (marker of markers; track marker) {
<map-marker [position]="marker.position" [label]="marker.label">
</map-marker>
}
</google-map>
// google-map.ts
import { Component, AfterViewInit, viewChild } from '@angular/core';
import { GoogleMap, GoogleMapsModule } from '@angular/google-maps';
// Strong typing for markers
interface MapMarker {
position: google.maps.LatLngLiteral;
label: google.maps.MarkerLabel;
options: google.maps.MarkerOptions;
title: string;
}
@Component({
selector: 'app-map-js',
templateUrl: './map-js.html',
styleUrls: ['./map-js.scss'],
imports: [GoogleMapsModule],
standalone: true, // required if no NgModule
})
export class MapJs implements AfterViewInit {
public markers: MapMarker[] = [];
public zoom = 4;
// Google Map reference (new Angular signal-style viewChild)
readonly map = viewChild.required(GoogleMap);
ngOnInit() {
this.markers.push({
position: { lat: 40.4168, lng: -3.7038 },
label: { color: 'black', text: 'Madrid' },
options: {
draggable: true,
animation: google.maps.Animation.DROP,
},
title: 'Madrid',
});
this.markers.push({
position: { lat: 40.4168, lng: -3.7038 },
label: { color: 'black', text: 'Madrid' },
options: { draggable: true, animation: google.maps.Animation.DROP },
title: 'Madrid',
});
}
ngAfterViewInit() {
const mapInstance = this.map().googleMap;
if (mapInstance) {
const streetView = mapInstance.getStreetView();
streetView.setOptions({
position: { lat: 38.9938386, lng: -77.2515373 },
pov: { heading: 70, pitch: -10 },
});
streetView.setVisible(true);
}
}
}
Supplemental
Installing and usage
npm i @bluehalo/ngx-leaflet
// leaflet-map.html
<div class="map-height" leaflet [leafletOptions]="options1"></div>
// leaflet-map.ts
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { LeafletModule } from '@bluehalo/ngx-leaflet';
import * as L from 'leaflet';
@Component({
selector: 'app-leaflet-map',
templateUrl: './leaflet-map.html',
styleUrls: ['./leaflet-map.scss'],
imports: [CommonModule, LeafletModule],
})
export class LeafletMap {
options1 = {
layers: [
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '...',
}),
],
zoom: 5,
center: L.latLng(46.879966, -121.726909),
};
//Second map
layersControl = {
baseLayers: {
'Open Street Map': L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '...',
}),
'Open Cycle Map': L.tileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '...',
}),
},
overlays: {
'Big Circle': L.circle([46.95, -122], { radius: 5000 }),
'Big Square': L.polygon([
[46.8, -121.55],
[46.9, -121.55],
[46.9, -121.7],
[46.8, -121.7],
]),
},
};
options2 = {
layers: [
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 50,
attribution: '...',
}),
],
zoom: 5,
center: L.latLng(46.879966, -121.726909),
};
//Third map
map: L.Map;
options3 = {
layers: [
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '',
}),
],
zoom: 7,
center: L.latLng(47.482023, -1),
};
//Forth map
map4: L.Map;
homeCoords = {
lat: 23.810331,
lon: 90.412521,
};
popupText = 'Some popup text';
markerIcon = {
icon: L.icon({
iconSize: [25, 41],
iconAnchor: [10, 41],
popupAnchor: [2, -40],
iconUrl: 'assets/images/marker-icon.png',
shadowUrl: 'assets/images/marker-shadow.png',
}),
};
options4 = {
layers: [
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '',
}),
],
zoom: 5,
center: L.latLng(this.homeCoords.lat, this.homeCoords.lon),
};
initMarkers() {
const popupInfo = `${this.popupText}`;
L.marker([this.homeCoords.lat, this.homeCoords.lon], this.markerIcon)
.addTo(this.map4)
.bindPopup(popupInfo);
}
onMapReady4(map: L.Map) {
this.map4 = map;
this.initMarkers();
}
}
Supplemental
Editors
Installing and usage
npm i ngx-editor
// ngx.html
<div class="NgxEditor__Wrapper">
<ngx-editor-menu [editor]="editor"> </ngx-editor-menu>
<ngx-editor [editor]="editor" [ngModel]="html" [disabled]="false"
[placeholder]="'Type here...'"></ngx-editor>
</div>
// ngx.ts
import { Component } from '@angular/core';
import { Breadcrumb } from '../../../shared/components/breadcrumb/breadcrumb';
import { Editor, NgxEditorModule } from 'ngx-editor';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-ngx-editors',
templateUrl: './ngx-editors.html',
styleUrls: ['./ngx-editors.scss'],
imports: [Breadcrumb,NgxEditorModule,FormsModule],
})
export class Ngxeditors {
public editor: Editor;
public html = '';
ngOnInit(): void {
this.editor = new Editor();
}
ngOnDestroy(): void {
this.editor.destroy();
}
}
Supplemental
Installing and usage
npm i @kolkov/angular-editor
// kolkov-editors.html
<angular-editor [placeholder]="'Enter text here...'" [(ngModel)]="htmlContent"></angular-editor>
// kolkov-editors.html
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AngularEditorModule } from '@kolkov/angular-editor';
@Component({
selector: 'app-mde-editors',
templateUrl: './mde-editors.html',
styleUrls: ['./mde-editors.scss'],
imports: [AngularEditorModule, FormsModule]
})
export class MdeEditors{
public htmlContent = '';
}
Supplemental