Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Support inheritance for @Input properties #291

Closed
Tomucha opened this issue Mar 5, 2017 · 3 comments
Closed

Support inheritance for @Input properties #291

Tomucha opened this issue Mar 5, 2017 · 3 comments

Comments

@Tomucha
Copy link

Tomucha commented Mar 5, 2017

This is not new, but I didn't find it in open issues here and I guess it should be documented:

 class BaseComponent {

   @Input()
   String name;

 }

 @Component(
   selector: 'child-component',
   template: '''
     <h1>Hello {{name}}!</h1>
     '''
 )
 class ChildComponent extends BaseComponent {
 
 }

Calling this component like this:

<child-component name="Angular"></child-component>

... renders "Hello !" instead of expected "Hello Angular!".

Real world example: I have a bunch of custom "input" components of all kind and they all can be "required", "readonly", "disabled", ... It make sense to define these properties in shared parent or in a mixin ...

Just another case for #48 :-)

@chalin
Copy link
Collaborator

chalin commented Mar 15, 2017

Generally speaking, I'm not sure that the semantics of inheritance for component metadata properties has been fully nailed down.

Anyhow, a workaround to the issue you mention is, of course, to provide a complete list of supported inputs and or output in the annotation of ChildComponent:

@Component(...,
    inputs: const ['name'], // <***************************
    template: '<h1>Hello {{name}}</h1>'
)
class ChildComponent extends BaseComponent { }

cc @kwalrath

@matanlurey
Copy link
Contributor

This is really important to me, but yes, we need to figure out semantics. It will be post-V3.

@matanlurey
Copy link
Contributor

Duplicate of #231.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants