title: call method in ngOnInit
body: <p>I am trying to call a method if a cookie is detected on page load. If detected, it should load my apps dark theme.</p>
  
  <p>I'm using Angular 7 and 'ngx-cookie-service'.</p>
  
  <p>I can switch themes fine, but cannot figure out how to automatically switch theme when the cookie is detected.</p>
  
  <p>Here is the code for my theme switching service:</p>
  
  <pre><code>import { Injectable, OnInit } from '@angular/core';
  import { Subject } from 'rxjs';
  
  // Import Services
  import { CookieService } from 'ngx-cookie-service';
  
  @Injectable()
  export class ThemeSwitchService implements OnInit {
  
    constructor( private cookieService: CookieService ) { }
  
    private _themeDark: Subject&lt;boolean&gt; = new Subject&lt;boolean&gt;();
  
    isThemeDark = this._themeDark.asObservable();
  
    ngOnInit(): void {
      const cookieValue: string = this.cookieService.get('DarkTheme');
      if (cookieValue === 'True') {
        setDarkTheme();
        console.log('Dark theme active.')
      }
    }
  
    setDarkTheme(isThemeDark: boolean) {
      this._themeDark.next(isThemeDark);
      if (isThemeDark) {
        this.cookieService.set('DarkTheme', 'True');
        console.log('Dark theme activated.')
      } else {
        this.cookieService.delete('DarkTheme');
        console.log('Dark theme deactivated.');
      }
    }
  }
  </code></pre>
  
  <p>My hope was to be able to call the theme switching method within ngOnInit, but I can't seem to get it working. This error shows in terminal: <code>ERROR in src/app/core/services/theme-switch.service.ts(20,7): error TS2663: Cannot find name 'setDarkTheme'. Did you mean the instance member 'this.setDarkTheme'?</code></p>