InterviewHubPRO
Section Overview
Q110

Question 110 of 283

Part 5: Animations, Service Workers, Ivy Engine & Builders (101 - 123)

39%
Angular & Signals (283 Qs)•Part 5: Animations, Service Workers, Ivy Engine & Builders (101 - 123)

What are the differences between AngularJS and Angular with respect to dependency injection?

Dependency injection is a common component in both AngularJS and Angular, but there are some key differences between the two frameworks in how it actually works.

AngularJSAngular
Dependency injection tokens are always stringsTokens can have different types. They are often classes and sometimes can be strings.
There is exactly one injector even though it is a multi-module applicationsThere is a tree hierarchy of injectors, with a root injector and an additional injector for each component.

Practical Code Example

text
// Dependency Injection: AngularJS vs Angular:
// AngularJS: String-based DI (vulnerable to minification bugs without string array wrappers)
// Angular: Type-token based hierarchical DI with @Injectable() and compile-time verification