I'm running into an issue trying to utilize a function within a service that I believed was globally accessible. The service in question is named SavedNotificationService
:
import { Injectable } from '@angular/core';
@Injectable()
export class SavedNotificationService {
private showSavedNotification = false;
show(): void {
this.showSavedNotification = true;
}
hide(): void {
this.showSavedNotification = false;
}
}
I've imported this service in app.module.ts:
import { SavedNotificationService } from "./saved-notification.service";
@NgModule({
providers: [SavedNotificationService]
})
However, when attempting to call a function within the service, it indicates that it cannot be found. Despite making the service available in app.module, do I still need to import it in the specific component where I intend to use it? (Similar to the example below)
@Component({
providers: [SavedNotificationService]
})