Angular 2 - apply ngIf to a node element using @HostBinding

I am trying to install ngIf on a host element using @HostBinding decorator.

class ListItem { @HostBinding('ngIf') active: boolean = false; } 

And I get the error: I can not bind to 'ngIf', since this is not a well-known “list-item” property.

However, I see an answer here that seems to suggest this use.

+5
source share
1 answer

ngIf - directive and directives cannot be added dynamically. They apply only if the additive statically added to the component template matches the selector.

@HostBinding() only supports class. bindings class. , attr. and style. .

+6
source

Source: https://habr.com/ru/post/1258677/


All Articles