HostBindingMetadata

export class HostBindingMetadata

exported from angular2/core defined in angular2/src/core/metadata/directives.ts (line 1053)

Declares a host property binding.

Angular automatically checks host property bindings during change detection. If a binding changes, it will update the host element of the directive.

HostBindingMetadata takes an optional parameter that specifies the property name of the host element that will be updated. When not provided, the class property name is used.

Example

The following example creates a directive that sets the valid and invalid classes on the DOM element that has ngModel directive on it.

@Directive({selector: '[ngModel]'}) class NgModelStatus { constructor(public control:NgModel) {} @HostBinding('[class.valid]') get valid { return this.control.valid; } @HostBinding('[class.invalid]') get invalid { return this.control.invalid; } } @Component({ selector: 'app', template: `<input [(ngModel)]="prop">`, directives: [FORM_DIRECTIVES, NgModelStatus] }) class App { prop; } bootstrap(App);

Constructor

constructor(hostPropertyName?: string)

Not Yet Documented

Members

hostPropertyName : string

Not Yet Documented