Last active
June 29, 2020 17:07
-
-
Save Dornhoth/1f34f889bb3376af9211d5ee1ad76c07 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
import { Component, InjectionToken, Inject } from '@angular/core'; | |
export const TOKEN = new InjectionToken<string>('MyToken'); | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'], | |
providers: [{ provide: TOKEN, useValue: 'my injected object' }] | |
}) | |
export class AppComponent { | |
constructor(@Inject(TOKEN) public myInjectObject: string) { | |
console.log(myInjectObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment