All files / app app.component.ts

83.33% Statements 5/6
100% Branches 0/0
66.66% Functions 2/3
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                  1x     3x   3x     1x                
import { AfterViewInit, Component, ViewChild } from '@angular/core';
import { MatSidenavContent } from '@angular/material/sidenav';
import { AppController } from './app.controller';
 
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent implements AfterViewInit {
  @ViewChild(MatSidenavContent) sidenavContent!: MatSidenavContent;
 
  title = 'GitHub Users Search';
 
  constructor(private controller: AppController) {}
 
  ngAfterViewInit(): void {
    this.controller.scrollToTop$.subscribe(() => {
      this.sidenavContent.scrollTo({
        top: 0,
        behavior: 'smooth',
      });
    });
  }
}