1

Can someone explain me how is my HostBinding in nested component understand that we already have "isTablet" property and just add "is-tablet" class to my host element ?

Webstorm says that we have overrided base isTablet property but my child component has TRUE in this property.

I can't find any explanations in official documentation

  export abstract class DetailBase {
       @Input() isTablet: boolean = true;
  }

  export class ChildComponent extends DetailBase {
       @HostBinding('class.is-tablet') isTablet: boolean; //why it is TRUE ?
  }

1 Answer 1

1

It's Typescript-specific behaviour. If member of the class has not defined value at all, transpiled javascript doesn't include this member at all. Take a look at transpiled javascript here and here:

Because extended class has defined value for member isTablet, child class has access to isTablet through prototypal inheritance.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.