Last active
June 29, 2020 17:08
-
-
Save Dornhoth/5b6e4d55749359874506fcb087d4a67a 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 1', multi: true }, | |
{ provide: TOKEN, useValue: 'my injected object 2', multi: true }, | |
], | |
}) | |
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