I have a complex data structure that requires lots of inline editing. To make the code easier, much of the breaking down of components over this data structure has been placed into nested directives.
For example, here is an example of the data structure:
{
"pageElements":[
{
"id":1721,
"pageId":861,
"position":0,
"type":"Paragraph",
"text":"<p>Who is the captain of the Enterprise NX-01?</p>"
},
{
"id":1722,
"pageId":861,
"position":1,
"type":"Question",
"question":{
"id":1664,
"type":"ShortAnswer",
"successMessage":"You really know your captains!",
"hints":[
],
"answerAllowance":"SINGLE",
"minimumNumberOfKeywords":1,
"keywords":[
{
"id":45394,
"text":"John Archer",
"accuracy":0,
"ignoreCase":false
}
]
}
},
{
"id":2786,
"pageId":861,
"position":2,
"type":"Paragraph",
"text":"<p>fafadffadfda</p>"
}
]
}
Imagine the main page for this controller iterates over pageElements
:
<ol class="pageElements">
<li ng-repeat="pageElement in page.pageElements">
<!-- page-element directive uses $compile
to create a specific DOM based on pageElement.type -->
<div page-element ng-model="pageElement"></div>
</li>
</ol>
Now, let's imagine that some modifications of a single pageElement
occur within the page-element
directive (or some child directive). How do we get those modifications into the page.pageElements
list? For some reason, I can get changes to propagate to parent directives if they are just objects, but once the parent object is contained within a list, the updates no longer propagate.
How can I solve this? Is the problem really with ng-repeat
stopping the propagation upwards?