I am designing a text editing component. I have developed the basic text editor to a minimally viable state. Now, I want to be able to add the ability to implement field text / templates.
I am imagining that the markup will look something like this:
//basic text editor
<text-editor></text-editor>
//text editor with templates
<text-editor *templateProvider='templateProviderIdentifier'></text-editor>
//templates used on some future item
<not-yet-defined *templateProvider='templateProviderIdentifier'></not-yet-defined>
The Angular2 documentation for Directives indicates that the Directive Constructor can have the ElementRef injected, which gives the Attribute Directive access to the DOM Element, but how does an Attribute Directive gain access to the Controller?
I don't want to edit the text editor, because templates might be used elsewhere. Ideally, when the attribute appears on an element, the Directive grabs the associated controller and tests it for a usable interface. If detected, it modifies the Component by setting itself as a behavior modifier on the element, or as a decorator of a sub-object.
I'm looking for information on how an Attribute Directive can Access the Controller object and any tips or tricks or pitfalls that you all see in the approach I am planning.
For quick reference to the manual pages that I have read, I include the following links: