import { Injectable } from '@angular/core' ; @ Injectable ( ) export class InfinitelistService { addEventListener ( ele , eventType , callback ) { if ( ele . addEventListener ) { return ele . addEventListener ( eventType , callback , false ) ; } else if ( ele [ 'attachEvent' ] ) { return ele [ 'attachEvent' ] ( eventType , callback ) ; } else { return ele [ "on" + eventType ] = callback ; } } removeEventListener ( ele , eventType , callback ) { if ( ele . removeEventListener ) { return ele . removeEventListener ( eventType , callback , false ) ; } else if ( ele [ 'detachEvent' ] ) { return ele [ 'detachEvent' ] ( eventType , callback ) ; } else { return ele [ "on" + eventType ] = null ; } } isArray ( val ) { return Object . prototype . toString . call ( val ) === '[object Array]' ; } randomColor ( ) { return '#' + ( '00000' + ( Math . random ( ) * 0x1000000 << 0 ) . toString ( 16 ) ) . slice ( - 6 ) ; } isPureNumber ( val ) { if ( typeof val === 'number' || ! val ) return true ; else return false ; } }