Skip to content

docs(google-maps): use inject() instead of constructor injection in examples#32836

Merged
crisbeto merged 1 commit intoangular:mainfrom
yogeshwaran-c:docs/google-maps-use-inject
Mar 25, 2026
Merged

docs(google-maps): use inject() instead of constructor injection in examples#32836
crisbeto merged 1 commit intoangular:mainfrom
yogeshwaran-c:docs/google-maps-use-inject

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Documentation update.

What is the current behavior?

The MapGeocoder and MapDirectionsRenderer README examples use constructor
injection to obtain services. The MapDirectionsRenderer example is also
missing the import {map} from 'rxjs/operators' import and has inconsistent
indentation on the imports array.

What is the new behavior?

  • Use inject() instead of constructor injection, consistent with the modern
    Angular standalone pattern used across the rest of the docs.
  • Add the missing import {map} from 'rxjs/operators' to the directions
    renderer example so the code compiles as shown.
  • Fix indentation of the imports array in the directions renderer example.
  • Simplify the directions renderer example by using a field initializer instead
    of assigning inside the constructor.

Additional context

Both MapGeocoder and MapDirectionsService are providedIn: 'root', so they
work with inject() without any additional provider configuration.

@pullapprove pullapprove bot requested review from mmalerba and tjshiu February 23, 2026 20:47
@angular-robot angular-robot bot added area: docs Related to the documentation area: google-maps labels Feb 23, 2026
@mmalerba mmalerba removed their request for review February 24, 2026 19:12
@pullapprove pullapprove bot requested a review from andrewseguin February 24, 2026 19:13
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Mar 25, 2026
@crisbeto crisbeto merged commit 52bf902 into angular:main Mar 25, 2026
16 of 18 checks passed
@crisbeto
Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

crisbeto pushed a commit that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: docs Related to the documentation area: google-maps target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants