Created
July 8, 2018 14:53
-
-
Save xthecapx/bbdd919bec12a1d74645dc203a92da91 to your computer and use it in GitHub Desktop.
This file contains 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
// New instance of the service with new instance of the component | |
@Component({ | |
selector: 'app-component', | |
templateUrl: './app-component.component.html', | |
providers: [ MyService ] | |
}) | |
export class Component { | |
constructor(private serive: MyService) {} | |
} | |
// Same intance of the service available to all components | |
@NgModule({ | |
imports: [ Component ], | |
declarations: [ AppComponent, Component ], | |
bootstrap: [ AppComponent ], | |
providers: [ MyService ] | |
}) | |
export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment