AngularJs 2 Series: Binding The Host Element With @HostBinding

  • Home > JavaScript > Angular.js > AngularJs 2 Series: Binding The Host Element With @HostBinding
  • AngularJs 2 Series: Binding The Host Element With @HostBinding
  • The getColor() method acts as a property to the get ‘getter’ which simply returns the value of the color property.
  • You can also be a guest writer for Web Code Geeks and hone your writing skills!
  • All trademarks and registered trademarks appearing on Web Code Geeks are the property of their respective owners.

In one of the previous article Build Your Own Directive, I showed you how to build or develop a custom highlight attribute that highlights the text background with yellow. We made use of Renderer service to render an element with the background style color to yellow. The element reference (which contained the text) was obtained using ElementRef type. We bound the style.background attribute of that element with the value of yellow using the setElementStyle method of the Renderer service. In this article I will use the same Typescript class and show you the alternate way to highlight the hosting element. We will use something called as @HostBinding decorator or meta data.

@webcodegeeks: AngularJs 2 Series: Binding The Host Element With @HostBinding – Angular.js

service. Let’s walk through the code. First we define a property named

AngularJs 2 Series: Binding The Host Element With @HostBinding

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.