Skip to content

Instantly share code, notes, and snippets.

View sankarseran's full-sized avatar

sankaralingam seranthian sankarseran

View GitHub Profile
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'convert'
})
export class HoursToMin implements PipeTransform {
transform(value: string): any {
const d = Number(value || 0) * 3600;
const h = Math.floor(d / 3600);
const m = Math.floor(d % 3600 / 60);
import { Pipe, PipeTransform } from '@angular/core';
import utils from '../utils/utils';
@Pipe({
name: 'simpleAgo'
})
export class DateConvert implements PipeTransform {
transform(date: string): any {
// console.log('date in the pipe:', date);
let time = Number(date);
if ( time < 1000000000000) {
@sankarseran
sankarseran / simpleAgo.pipe.ts
Created March 27, 2018 13:52
This pipe will give a days ago until 7 days, after that it will return date.
import { Pipe, PipeTransform } from '@angular/core';
import utils from '../utils/utils';
@Pipe({
name: 'simpleAgo'
})
export class SimpleAgo implements PipeTransform {
transform(date: string): any {
let time = Number(date);
if ( time < 1000000000000) {
time = time * 1000;
import { Directive, HostListener, ElementRef, OnInit } from '@angular/core';
@Directive({ selector: '[InputValidator]' })
export class InputValidatorDirective implements OnInit {
el: any;
constructor(private elementRef: ElementRef) {
this.el = this.elementRef.nativeElement;
}