angular: Component with local properties doesn't inherit service from superclass

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior My BaseComponent injects a service (example: https://github.com/ebrehault/component-extension-example/blob/master/src/app/base-component/base-component.component.ts#L13). My CustomComponent inherits from BaseComponent (example: https://github.com/ebrehault/component-extension-example/blob/master/src/app/custom-component/custom-component.component.ts#L9) and it works fine, the service is properly injected. But my CustomWithproperty component which is also inheriting from BaseComponent but defines a custom property (example: https://github.com/ebrehault/component-extension-example/blob/master/src/app/custom-with-property/custom-with-property.component.ts#L11) does not work, the service is not injected.

Expected behavior The service should be injected.

Minimal reproduction of the problem with instructions

Here is an example generated with Angular CLI 1.0.0: https://github.com/ebrehault/component-extension-example

What is the motivation / use case for changing the behavior?

Adding custom properties (or methods) in a component should not break superclass injected services.

Note: it looks like a regression, as it used to work with Angular 2.4

Please tell us about your environment:

Ubuntu 16.10. npm 3.10.10 served with ng serve

  • Angular version: 4.0.0
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Chrome 56

  • Language: [all | TypeScript X.X | ES6/7 | ES5] Typescript 2.2.1

  • Node (for AoT issues): node --version =
    6.10.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 20 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@DzmitryShylovich, I’m sorry, we have hundreds of components! We are not “playing” with Angular, we are building a platform on it and this regression is important for us!
We counted a lot on this feature, please fix it @tbosch.

Works great! Thanks for the quick fix and release!