What could I have like parameter to @HostBinding decorator?
Asked Answered
F

2

5

Can't find documentation for it.

From examples I got 3 cases:

  • @HostBinding("attr.something")

  • @HostBinding("class.something")

  • @HostBinding("style.something")

but is there more?

Fantail answered 15/12, 2016 at 20:23 Comment(0)
O
7

As per written in this link by Thierry Templier who is also active in this group if I remember correctly :) Picture is from post from that website.

HostBinding

Offhand answered 15/12, 2016 at 22:6 Comment(0)
U
7

propertyName: references a property of the host with the propertyName name.

@HostBinding('value') value:string;

attr.attributeName: references an attribute of the host with the attributeName name. The initial value is set to the associated directive property. Setting a value in the property updates the attribute on the corresponding HTML element. Using the null value at this level removes the attribute on the HTML element.

@HostBinding('attr.role') role:string;

style.styleName: links a directive property to a style of the HTML element.

@HostBinding('style.width.px') width:number;

class.className: links a directive property to a class name of the HTML element. If the value is true, the class is added otherwise removed.

@HostBinding('class.someClass') condition:boolean;
Unbreathed answered 24/9, 2017 at 19:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.