shiva
shiva

Reputation: 764

Angular 2, which element properties can you bind to?

I'm trying to bind to clientWidth element property, but it errors that clientWidth is not property of the element I'm targeting.

Can you bind to any element property? and does it matter if it is read only?

Is this: <div [style.width.px]="width"> As valid as this: <div [clientWidth]="width">

Upvotes: 0

Views: 220

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657038

https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth

intElemClientWidth is an integer corresponding to the clientWidth of element in pixels. clientWidth is read–only.

You can do data binding with any property that is not read-only and to every input of an Angular component (and directives).

You can do event binding with every DOM event (also custom DOM events) and every output of Angular components (and directives)

Upvotes: 3

Related Questions