Skip to content

Comments

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

Open
yogeshwaran-c wants to merge 1 commit intoangular:mainfrom
yogeshwaran-c:docs/google-maps-use-inject
Open

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

Conversation

@yogeshwaran-c
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Related to the documentation area: google-maps

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant