Skip to content

View provider/provider info that's logged in the console is incorrect #55570

@HymanZHAN

Description

@HymanZHAN

Is this a bug report or a feature request?

  • Bug Report
  • Feature Request

Please provide the steps to reproduce the issue [Bug Report only]

  • Create a component with both providers and viewProviders
  • Inspect the DI information in the "Injector Tree" tab in Angular DevTools
  • Log different providers to the console
  • The value entry is incorrect

Please provide the expected behavior vs the actual behavior you encountered [Bug Report only]

Should log different providers accurately.

Please provide a screenshot if possible [Bug Report only]

BComponent:

@Component({
  selector: 'app-b',
  standalone: true,
  imports: [CComponent],
  providers: [
    {
      provide: Flower,
      useValue: new Flower('🌺'),
    },
  ],
  viewProviders: [
    {
      provide: Flower,
      useValue: new Flower('🌻'),
    },
  ],
  template: `
    B (<code>&#64;SkipSelf</code>): {{ flower.name }}
    <br />
    <app-c [prefix]="prefix" />
    <ng-content></ng-content>
  `,
})
export class BComponent {
  // ...
}

Screenshot 2024-04-28 121505
Screenshot 2024-04-28 121546

Notice how the second log has a discrepancy between provider.useValue and value:

Please provide the exception or error you saw [Bug Report only]

No response

Is this a browser-specific issue? If so, please specify the device, browser, and version. [Bug Report only]

No, I can reproduce it on both Firefox and Chrome.

Description [Feature Request only]

No response

Proposed solution [Feature Request only]

No response

Alternatives considered [Feature Request only]

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions