title: AngularJS: Connecting data to model in a directive
body: <p>My intent is to have some data displayed on a page and have any changes to it reflected in the model. However, the data needs to have specific manipulations applied before display, and remain connected to the model.</p>
  <p>For example, if the data is an html fragment, I'd be wrapping it in a DIV with attribute contentEditable. However if it's a set of options, I'll be wrapping it in a UL and LIs, each of which containing a SPAN with attribute contentEditable.</p>
  <p>In each case, the contentEditable part should remain connected to the model.</p>
  <p>I'm working on a JSFiddle to try to make some inroads (starting with the case where the item is an html fragment) and have labelled points (2) and (3) where I'm currently stuck. Trying to:</p>
  <pre><code>a) Get the watch function to notice a change to the content
  b) Maintain the two way binding between the displayed editable content and the model
  </code></pre>
  <p>My fiddle is here: <a href="http://jsfiddle.net/rAXmV/" rel="nofollow noreferrer">http://jsfiddle.net/rAXmV/</a></p>
  <p>Any suggestions for how I could approach this would be much appreciated.</p>
  <h2>Edit</h2>
  <p>I've been looking into using $compile to generate the output structure and it does look like it is getting the relevant data passed in. However it's still disconnected from the model:</p>
  <p><a href="http://jsfiddle.net/xRQ7M/" rel="nofollow noreferrer">http://jsfiddle.net/xRQ7M/</a></p>
  <h2>Edit 2</h2>
  <p>After some more hacking I have a working implementation for the contenteditable areas within the supplied HTML. It picks up the changes on focusout, which is the only way I could find that bubbled up from contenteditable areas within the processed html.</p>
  <p>A more permanent JSFiddle is here: <a href="http://jsfiddle.net/donovanh/q6auY/" rel="nofollow noreferrer">http://jsfiddle.net/donovanh/q6auY/</a></p>