fuse-angular/src/@fuse/services/utils/utils.service.ts
2021-04-15 17:13:46 +03:00

37 lines
824 B
TypeScript

import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class FuseUtilsService
{
/**
* Constructor
*/
constructor()
{
}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Generates a random id
*
* @param length
*/
randomId(length: number = 10): string
{
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let name = '';
for ( let i = 0; i < 10; i++ )
{
name += chars.charAt(Math.floor(Math.random() * chars.length));
}
return name;
}
}