Embedding plugins
Add these imports to a component where you want to embed another plugin:
Inject Angular2PluginEmbedActions into your component constructor:
In the component template prepare a container where you want to embed the plugin:
In the component class add a reference to the container:
In the component class add a reference to the embedded instance:
Everything is ready to start embedding, you just need to know the pluginId that you want to embed:
#
How to interact with embedded pluginIf the main component of embedded plugin declares Input and Output properties then you can interact with it. ApplicationManager provides methods to set Input properties and get Output properties of the embedded plugin. Suppose, that the embedded plugin declares Input and Output properties like this:
Obtain a reference to AppicationManager in your component constructor:
Note: We are unable to inject AppicationManager
with @Inject()
until an AoT-compiler issue with namespaces is resolved: angular/angular#15613
Now you can set sampleInput
property, obtain sampleOutput
property and subscribe to it:
#
How to destroy embedded pluginThere is no special API to destroy embedded plugin. If you want to destroy the embedded plugin just clear the container for the embedded plugin and set embeddedInstance
to null:
#
How to style a container for the embedded pluginIt is hard to give a universal recipe for a container style. At least, the container needs position: "relative"
because the embedded plugin may have absolutely positioned elements. Here is sample styles you can start with if your component utilizes flexbox layout:
#
Applications that use embeddingWorkflow app demonstrates advanced usage.