Angular 7: Can't bind to 'directive' since it isn't a known property of 'element' Angular 7: Can't bind to 'directive' since it isn't a known property of 'element' angular angular

Angular 7: Can't bind to 'directive' since it isn't a known property of 'element'


Looking at the documentation here: https://angular.io/guide/attribute-directives

This type of selector:

@Directive({  selector: '[appInputFormat]'})

Builds an attribute directive.

It's the brackets ([]) that make it an attribute selector.

So it has to be used as an attribute like this:

<input class="text" appInputFormat>

Brackets when you define the selector, but no brackets in the Html when you use the directive.


proper syntax is:

<input class="text" appInputFormat>

You put things in brackets when they're accepting an input, as in if you also declared an input of the same name on the directive, similarly you can use parens if you declare an output of the same name.