Skip to content

Instantly share code, notes, and snippets.

@alxhub
Last active August 16, 2022 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alxhub/50ee9a5482940d27b82561416a4ae569 to your computer and use it in GitHub Desktop.
Save alxhub/50ee9a5482940d27b82561416a4ae569 to your computer and use it in GitHub Desktop.
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