Interacting with the Control
There are broadly four types of interaction with the Control from the Angular Component:
Using Structural Directives to control the control,
interactions between
Feed Data Back
Some controls are associated to data returned to the app. The word choice is deliberate, I give the example of location data that is "associated" with the location control but generated by the map.
My prefered methid to expose the data to the app is to output the data from the control component even thought the data is coming from the map. This improves readability and means that the listeners are created and destroyed correctly as the control is clawed up and clawed down in app DOM.
So:
the listeners should be setup when the control is added to the map,
the listeners should be removed when the component is destroyed,
there should be an Output property for the value and new values should be
.emit()
'ed on this property.IN the parent component, the directive should listen to the value and call a local method when it receives a new value.
e.g.
and
Worked Examples
For some worked examples of these issues and some discussion, see:
The Demo code is included in this stackblitz
Last updated