Created
September 11, 2020 19:19
-
-
Save Dornhoth/cf0d58f30d0712e556ac2685c282e8d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { SingletonService } from './singleton.service'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'] | |
}) | |
export class AppComponent implements OnInit { | |
constructor( | |
private singletonService: SingletonService | |
) { } | |
ngOnInit(): void { | |
this.singletonService.someMethod(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { AppComponent } from './app.component'; | |
import { ModuleAModule } from './moduleA/moduleA.module'; | |
import { SingletonService } from './singleton.service'; | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
BrowserModule, | |
ModuleAModule, | |
], | |
providers: [SingletonService], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { SingletonService } from '../singleton.service'; | |
@Component({ | |
selector: 'app-module-a', | |
templateUrl: './moduleA.component.html', | |
styleUrls: ['./moduleA.component.scss'] | |
}) | |
export class ModuleAComponent implements OnInit { | |
constructor( | |
private singletonService: SingletonService | |
) { } | |
ngOnInit(): void { | |
this.singletonService.someMethod(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import { SingletonService } from '../singleton.service'; | |
import { ModuleAComponent } from './moduleA.component'; | |
@NgModule({ | |
declarations: [ | |
ModuleAComponent | |
], | |
exports: [ModuleAComponent], | |
providers: [SingletonService], | |
}) | |
export class ModuleAModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment