ngx-range
Version:
An Angular structural directive to enumerate over a range of numbers
69 lines (63 loc) • 3.11 kB
JavaScript
import * as i0 from '@angular/core';
import { Input, Directive, NgModule } from '@angular/core';
class NgxRangeDirectiveContext {
constructor($implicit) {
this.$implicit = $implicit;
}
}
class NgxRangeDirective {
constructor(templateRef, viewContainer) {
this.templateRef = templateRef;
this.viewContainer = viewContainer;
this.ngxRangeFrom = 0;
this.ngxRangeTo = 0;
this.ngxRangeBy = 1;
}
ngOnChanges(changes) {
if (changes['ngxRangeFrom'] ||
changes['ngxRangeTo'] ||
changes['ngxRangeBy']) {
this.viewContainer.clear();
let index = 0;
for (let i = this.ngxRangeFrom; i < this.ngxRangeTo; i += this.ngxRangeBy) {
this.viewContainer.createEmbeddedView(this.templateRef, new NgxRangeDirectiveContext(i), index++);
}
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: NgxRangeDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.3", type: NgxRangeDirective, isStandalone: false, selector: "[ngxRange]", inputs: { ngxRangeFrom: "ngxRangeFrom", ngxRangeTo: "ngxRangeTo", ngxRangeBy: "ngxRangeBy" }, usesOnChanges: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: NgxRangeDirective, decorators: [{
type: Directive,
args: [{
selector: '[ngxRange]',
standalone: false,
}]
}], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }], propDecorators: { ngxRangeFrom: [{
type: Input
}], ngxRangeTo: [{
type: Input
}], ngxRangeBy: [{
type: Input
}] } });
class NgxRangeModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: NgxRangeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.3", ngImport: i0, type: NgxRangeModule, declarations: [NgxRangeDirective], exports: [NgxRangeDirective] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: NgxRangeModule }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: NgxRangeModule, decorators: [{
type: NgModule,
args: [{
declarations: [NgxRangeDirective],
imports: [],
exports: [NgxRangeDirective],
}]
}] });
/*
* Public API Surface of ngx-range
*/
/**
* Generated bundle index. Do not edit.
*/
export { NgxRangeDirective, NgxRangeDirectiveContext, NgxRangeModule };
//# sourceMappingURL=ngx-range.mjs.map