You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

47 lines
1.1 KiB

import * as i0 from '@angular/core';
import { inject, APP_ID, Injectable } from '@angular/core';
const counters = {};
class _IdGenerator {
_appId = inject(APP_ID);
static _infix = `a${Math.floor(Math.random() * 100000).toString()}`;
getId(prefix, randomize = false) {
if (this._appId !== 'ng') {
prefix += this._appId;
}
if (!counters.hasOwnProperty(prefix)) {
counters[prefix] = 0;
}
return `${prefix}${randomize ? _IdGenerator._infix + '-' : ''}${counters[prefix]++}`;
}
static ɵfac = i0.ɵɵngDeclareFactory({
minVersion: "12.0.0",
version: "21.0.3",
ngImport: i0,
type: _IdGenerator,
deps: [],
target: i0.ɵɵFactoryTarget.Injectable
});
static ɵprov = i0.ɵɵngDeclareInjectable({
minVersion: "12.0.0",
version: "21.0.3",
ngImport: i0,
type: _IdGenerator,
providedIn: 'root'
});
}
i0.ɵɵngDeclareClassMetadata({
minVersion: "12.0.0",
version: "21.0.3",
ngImport: i0,
type: _IdGenerator,
decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}]
});
export { _IdGenerator };
//# sourceMappingURL=_id-generator-chunk.mjs.map