Attribute, class, style and event bindings
Learn Attribute, class, style and event bindings (Module 5 · Templates and Data Binding, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Binding HTML attributes, class and style • Some attributes have no matching DOM property (aria-label, colspan, data-*). Bind them with [attr.name] . To toggle a CSS class use class binding ( [class.active]="isOn" ); to set an inline style use style binding ( [style.width.px]="w" ). Think of switches on a control panel that you flip from your data.