Components have multiple ways of interacting with other components and services. When possible, interaction through commands and operations should be preferred, as this introduces the loosest coupling. When you need stronger coupling and direct access to the API, then model imports or service injection can be used. A good example of this is needing direct access to the ArcGIS Map, which can be exposed by importing the map model.
Components can interact with each other through their respective models. A model can either declare that it is exported, like the map model, or that it imports a model.
Declaring a model as exported exposes it to other components for importing.
@importModeldecorator will tell the component to attempt to retrieve a reference to the given model type, according to the model binding rules
Components like the
<compass> import the map model, and this allows them to respond to changes in the maps state through the map model.
Custom components can also import models and interact with them. The import must be done in the model of the component. This tight coupling can allow deeper access to other components models, but also negates the advantages of the abstraction of commands and operations.
The property decorated by
@importModel is completely managed by Geocortex Web and should never be modified or serialized in app config. Its value can change at any time, e.g. to and from undefined, or from one model instance to a completely different one. The component needs to react appropriately to these changes and not make any assumptions about its current value.
You can mark a model as exported by adding the
@exportModel decorator to the model class. The following example shows a model that is exported, and then imported by another model and used.
Models are imported with the
itemType name that they are registered with.
- Exported Model
- Importing Model
- Importing Model Component
Components can interact with built-in Geocortex Web services. Through services, they can interact with the map, application context, workflows, and more. Services can only be injected into a components through their associated models. Learn more about how to inject a service into a component.
Build a Custom Component that Imports the Map Model
Follow step by step instructions to import the map model into a custom component
Learn how to Interact with Services
Learn about how components can interact with built-in or custom services
Learn how Components are Bound to Models in the Layout
Learn how layout structure can be used to bind components to their required models