title: Undefined: including a service inside another service - Angular 2
body: <p>My NotificationService is included in my GlobalService but when I call any NotificactionService function it says: Cannot read properties of undefined (reading 'warn'). What I'm doing wrong? I think it is related to scope issues.</p>
  <p>Here is my <strong>NotificationService</strong> code</p>
  <pre><code>import { Injectable } from '@angular/core';
  import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
  
  @Injectable({
    providedIn: 'root'
  })
  
  export class NotificationService {
  
    constructor(public snackBar: MatSnackBar) { }
  
    config : MatSnackBarConfig = {
      duration: 3000,
      horizontalPosition: 'right',
      verticalPosition: 'bottom'
  
    }
  
    warn(msg:string):void{
      this.config['panelClass'] = ['notification', 'warn'];
      this.snackBar.open(msg, '', this.config);
    }
  
  }
  </code></pre>
  <p>Here is my <strong>GlobalService</strong> code</p>
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
  import { throwError } from 'rxjs/internal/observable/throwError';
  import { NotificationService } from '@services/notification.service';
  
  @Injectable({
    providedIn: 'root'
  })
  export class GlobalService {
  
    constructor(private notification_srv:NotificationService){}
  
    public handleError(error: HttpErrorResponse) {
      if (error.status === 0) {
        console.error('An error occurred:', error.error);
        this.notification_srv.warn(`An error occurred: ${error.error}`)
      } else {
        console.error(
          `Backend returned code ${error.status}, body was: `, error.error);
        this.notification_srv.warn('Backend returned code')
      }
      return throwError('Something bad happened; please try again later.');
    }
  }
  
  </code></pre>