DEV Community

Nhan Nguyen
Nhan Nguyen

Posted on

⭐ Angular - DI with inject function⭐

Example of Token Helper

👉 token.ts
➖ Create an InjectionToken with an initial value
➖ Create a Provider function

👉 Usage:
➖ Provide TOKEN in the component.
➖ Inject TOKEN into the component.

You can run it on Stackblitz and fork the project to debug.


I hope you found it useful. Thanks for reading. 🙏
Let's get connected! You can find me on:

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay