Question: How can i print output like this?  

1 2 3 4  

5 6 7 8  

9 10  

i had tried this code but not luck.

```
for ($i = 1; $i<=10; $i++)
{
    if ($i <= 4)
    {
        echo $i;    
        if ($i >= 4){
            echo'<br>';
            for($x = $i; $x<=10; $x++){
                echo $x;
            }
        }
    }
}

```

this code output look like this.

1234  

45678910

Answer: 
```ts
ngOnInit() {
    window.addEventListener("scroll", this._scrollListener.bind(this);
}

```

or probably a better solution

```ts
@HostListener('window:scroll', ['$event'])
private _scrollListener(event){
    console.log("inside the scroll listener; this: ",this);
    this._zone.run(() => {
        this.checkForLazyLoad = !this.checkForLazyLoad;
    })
}

```

this way you can't unregister the event imperatively, but it's unregistered automatically when the component is removed.
I solved this issue by simply using **arrow function** :

```
private _scrollListener(event){
    console.log("inside the scroll listener; this: ",this);
    this._zone.run(() => {
        this.checkForLazyLoad = !this.checkForLazyLoad;
    })
}

ngOnInit() {
    window.addEventListener("scroll", (event) => {
        this._scrollListener(event);
    });
}

```