<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-using-angular-s-inject-function-has-saved-me-1000-lines-of-code-gvhs2feil" -->

---
title: How Using Angular’s inject() Function Has Saved Me 1000...
description: The inject() function in Angular allows for cleaner and more readable code by injecting dependencies in a different way than using constructors. It also...
canonical: https://daily.dev/posts/how-using-angular-s-inject-function-has-saved-me-1000-lines-of-code-gvhs2feil
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How Using Angular’s inject() Function Has Saved Me 1000 Lines of Code | daily.dev
og:description: The inject() function in Angular allows for cleaner and more readable code by injecting dependencies in a different way than using constructors. It also...
og:url: https://daily.dev/posts/how-using-angular-s-inject-function-has-saved-me-1000-lines-of-code-gvhs2feil
og:image: https://api.daily.dev/og/posts/gvhS2fEil.png
og:image:alt: How Using Angular’s inject() Function Has Saved Me 1000 Lines of Code
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How Using Angular’s inject() Function Has Saved Me 1000 Lines of Code

**[JavaScript in Plain English](https://daily.dev/sources/jsPlainEnglish)** · 3 min read · 42 upvotes · 3 comments

## Summary

The inject() function in Angular allows for cleaner and more readable code by injecting dependencies in a different way than using constructors. It also provides better inheritance capabilities and can lead to significant reduction in lines of code.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://javascript.plainenglish.io/how-using-the-angulars-inject-function-has-saved-me-1000-lines-of-code-82b699183da8>

## Community discussion

Top comments from developers on daily.dev.

**@sebconejo** · 1 upvotes

> Thanks for sharing it. But... It doesn't really make the code more readable. Does it really do it for you?

**@sqwzzz** · 0 upvotes

> thanks man! It's really cool that i found your article now. Just started to implement inheritance recently and it would help me optimize this thing!

**@hbui** · 0 upvotes

> Excellent!

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#angular](https://daily.dev/tags/angular), [#dependency-injection](https://daily.dev/tags/dependency-injection)

[View this post on daily.dev](https://daily.dev/posts/how-using-angular-s-inject-function-has-saved-me-1000-lines-of-code-gvhs2feil)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How Using Angular’s inject() Function Has Saved Me 1000 Lines of Code","url":"https://daily.dev/posts/how-using-angular-s-inject-function-has-saved-me-1000-lines-of-code-gvhs2feil","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-using-angular-s-inject-function-has-saved-me-1000-lines-of-code-gvhs2feil"},"datePublished":"2024-04-19T06:36:42.776Z","dateModified":"2024-05-09T09:03:00.647Z","description":"The inject() function in Angular allows for cleaner and more readable code by injecting dependencies in a different way than using constructors. It also...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/001e6fbfba0fcb326ba02f9f7f2d22de?_a=AQAEufR","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/001e6fbfba0fcb326ba02f9f7f2d22de?_a=AQAEufR","isAccessibleForFree":true,"articleSection":"JavaScript in Plain English","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"JavaScript in Plain English","logo":"https://media.daily.dev/image/upload/s--Dg5QTRuI--/f_auto,q_auto/v1686665538/logos/pe","url":"https://daily.dev/sources/jsPlainEnglish"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/how-using-angular-s-inject-function-has-saved-me-1000-lines-of-code-gvhs2feil","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":42},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":"angular,dependency-injection","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"JavaScript in Plain English","item":"https://daily.dev/sources/jsPlainEnglish"},{"@type":"ListItem","position":3,"name":"How Using Angular’s inject() Function Has Saved Me 1000 Lines of Code"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/how-using-angular-s-inject-function-has-saved-me-1000-lines-of-code-gvhs2feil","comment":[{"@type":"Comment","text":"Thanks for sharing it. But… It doesn’t really make the code more readable. Does it really do it for you?","datePublished":"2024-04-29T12:19:10.580Z","url":"https://daily.dev/posts/gvhS2fEil#c-sc82NSBsV","author":{"@type":"Person","name":"Sébastien Conejo","url":"https://daily.dev/sebconejo","image":"https://media.daily.dev/image/upload/s--BA_P-9W6--/f_auto/v1742836511/avatars/avatar_dU65w8mTZwguzlhljjMh9"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"thanks man! It’s really cool that i found your article now. Just started to implement inheritance recently and it would help me optimize this thing!","datePublished":"2024-04-26T20:20:12.153Z","url":"https://daily.dev/posts/gvhS2fEil#c-JmAvQHyzc","author":{"@type":"Person","name":"Roman Hordiichuk","url":"https://daily.dev/sqwzzz","image":"https://media.daily.dev/image/upload/s--WhdzX-OQ--/f_auto/v1712434895/avatars/avatar_q65iMMMokRnWVluOwEWPm"}},{"@type":"Comment","text":"Excellent!","datePublished":"2024-05-10T07:06:54.027Z","url":"https://daily.dev/posts/gvhS2fEil#c-Nk2YXjlS8","author":{"@type":"Person","name":"Hung Bui","url":"https://daily.dev/hbui","image":"https://avatars.githubusercontent.com/u/242059?v=4"}}]}
```

