When wrapping a property in brackets []
you’re trying to bind to it. So you have to declare it as an @Input
.
import { Directive, Input } from '@angular/core';
@Directive({
selector: '[appContenteditableModel]'
})
export class ContenteditableModelDirective {
@Input()
appContenteditableModel: string;
constructor() { }
}
The important part is, that the member (appContenteditableModel
) needs to be named as the property on the DOM node (and, in this case, the directive selector).