import { Injectable } from "@angular/core" ; @ Injectable ( { providedIn : 'root' } ) export class ListService { array = [ ] ; sum = 40 ; direction = "" ; constructor ( ) { this . appendItems ( 0 , this . sum ) ; } addItems ( startIndex , endIndex , arrMethod ) { } appendItems ( startIndex , endIndex ) { this . array = this . array . concat ( Array ( endIndex ) . fill ( 0 ) . map ( ( el , i ) => `${ i } -> ${ this . generateWord ( ) }` ) ) ; } prependItems ( startIndex , endIndex ) { this . array = Array ( endIndex ) . fill ( 0 ) . map ( ( el , i ) => `${ i } -> ${ this . generateWord ( ) }` ) . concat ( this . array . concat ( ) ) ; } setDirectionDown ( ) { const start = this . sum ; this . sum += 10 ; this . appendItems ( start , this . sum ) ; this . direction = "down" ; } setDirectionUp ( ) { const start = this . sum ; this . sum += 10 ; this . prependItems ( start , this . sum ) ; this . direction = "up" ; } generateWord ( ) { return window [ "chance" ] . word ( ) ; } }