You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RTL/src/app/shared/services/common.service.ts

21 lines
460 B
TypeScript

import { Injectable } from '@angular/core';
@Injectable()
export class CommonService {
sortDescByKey(array, key) {
return array.sort(function (a, b) {
const x = a[key];
const y = b[key];
return ((x > y) ? -1 : ((x < y) ? 1 : 0));
});
}
camelCase(str) {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => {
return index == 0 ? word.toLowerCase() : word.toUpperCase();
}).replace(/\s+/g, '');
}
}