Last active
August 16, 2022 16:57
-
-
Save alxhub/50ee9a5482940d27b82561416a4ae569 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
const HERO_API_URL = new InjectionToken<string>('HERO_API_URL'); | |
@Injectable() | |
export class HeroService { | |
// old way, 'string' has to be declared and is not type checked | |
constructor(@Inject(HERO_API_URL) private apiUrl: string) {} | |
// new way, type is automatically correct | |
private apiUrl = inject(HERO_API_URL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment