Skip to content

Conversation

@fahrigedik
Copy link
Member

Description

Resolves #23231

This PR refactors all Angular services, components, and directives in the repository to use the Angular v14+ inject() function for dependency injection instead of constructor-based DI. All DI dependencies are now initialized as class properties using inject(), and constructors have been removed or simplified where appropriate. This change aligns the codebase with Angular's latest best practices for dependency injection, improves code readability, and prepares the project for future Angular versions.

Highlights:

All services, components, and directives now use inject() for DI.
Constructors that only existed for DI have been removed.
No functional or API changes were made; only the DI pattern was updated.
No breaking changes for consumers unless they relied on constructor injection in extended classes.
No screenshots or GIFs are required as this is a code refactor.

Checklist

  • I fully tested it as developer / designer and created unit / integration tests
  • I documented it (or no need to document or I will create a separate documentation issue)

How to test it?

Run the application and ensure all features work as before.
Pay special attention to areas where services, components, or directives are injected.
Run all existing unit and integration tests to confirm there are no regressions.

for @sumeyyeKurtulus

Migration Options & Rationale

  1. Migration Path: abp
    Choice: Migrate entire project
    Rationale: Ensure consistency across all code and avoid mixed DI patterns.

  2. Abstract Classes Migration: Yes

  3. Backwards Compatible Constructors: No

  4. Optional Inject Non-nullable: Yes

@fahrigedik fahrigedik added this to the 10.0-preview milestone Jul 8, 2025
Updated PageToolbarComponent and LazyStyleHandler initialization to remove the unused Injector parameter from their constructors and factory functions. This simplifies instantiation and aligns with recent refactoring.
Copy link
Contributor

@sumeyyeKurtulus sumeyyeKurtulus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @fahrigedik , it looks nice and neat other than the points I mentioned above.

fahrigedik and others added 2 commits July 9, 2025 11:33
Eliminated unused imports from several components and directives to improve code clarity and reduce bundle size. Added an explicit constructor to DateParserFormatter for consistency. No functional changes were made.
@sumeyyeKurtulus sumeyyeKurtulus self-requested a review July 9, 2025 10:02
Copy link
Contributor

@yagmurcelk yagmurcelk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get an error when I run this command (yarn nx build core --skip-nx-cache --verbose)

image

Updated MockPermissionService and MockRestService to call their super constructors without arguments, aligning with possible changes in the base class constructors. This simplifies the instantiation logic and removes unnecessary dependencies from the mock implementations.
@fahrigedik
Copy link
Member Author

fahrigedik commented Jul 9, 2025

I get an error when I run this command (yarn nx build core --skip-nx-cache --verbose)

image

i fixed this error

Copy link
Contributor

@yagmurcelk yagmurcelk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting an error on the volo side

image

@fahrigedik fahrigedik requested a review from yagmurcelk July 10, 2025 12:05
@gizemmutukurt gizemmutukurt requested review from oykuermann and removed request for oykuermann and yagmurcelk July 14, 2025 06:34
@fahrigedik fahrigedik requested a review from yagmurcelk July 15, 2025 10:14
Copy link
Contributor

@yagmurcelk yagmurcelk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get an error when I run the yarn copy-to:app-pro command on the volo side
image

@yagmurcelk yagmurcelk self-requested a review July 16, 2025 10:23
Copy link
Contributor

@yagmurcelk yagmurcelk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • image
  • It gives an error in the console on the login page.
image
  • After the user logs in, the pages do not work normally for a while, but then they are fixed. Even though I log in, the login button continues to appear.
Apex_1752662699965.webm
image

@fahrigedik fahrigedik requested a review from yagmurcelk July 16, 2025 13:14
@fahrigedik
Copy link
Member Author

fahrigedik commented Jul 17, 2025

Hi @yagmurcelk These errors occur because the scripts are not loaded and I don't get them. would you like someone else to test it?

@yagmurcelk yagmurcelk merged commit 5219175 into dev Jul 17, 2025
2 of 3 checks passed
@yagmurcelk yagmurcelk deleted the issue-23231-v2 branch July 17, 2025 07:32
@fahrigedik fahrigedik restored the issue-23231-v2 branch August 25, 2025 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Angular - Migration to the inject function

4 participants