mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-04-19 06:42:35 +00:00
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { IsActiveMatchOptions } from '@angular/router';
|
|
|
|
@Injectable({providedIn: 'root'})
|
|
export class FuseUtilsService
|
|
{
|
|
/**
|
|
* Constructor
|
|
*/
|
|
constructor()
|
|
{
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------------------------------
|
|
// @ Accessors
|
|
// -----------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
* Get the equivalent "IsActiveMatchOptions" options for "exact = true".
|
|
*/
|
|
get exactMatchOptions(): IsActiveMatchOptions
|
|
{
|
|
return {
|
|
paths : 'exact',
|
|
fragment : 'ignored',
|
|
matrixParams: 'ignored',
|
|
queryParams : 'exact',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get the equivalent "IsActiveMatchOptions" options for "exact = false".
|
|
*/
|
|
get subsetMatchOptions(): IsActiveMatchOptions
|
|
{
|
|
return {
|
|
paths : 'subset',
|
|
fragment : 'ignored',
|
|
matrixParams: 'ignored',
|
|
queryParams : 'subset',
|
|
};
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------------------------------
|
|
// @ 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;
|
|
}
|
|
}
|