title: ion-tabs run function after selection
body: <p>I have a ionic app with a tabbed interface that has a code-editor on one tab and a preview area on another tab (that uses the user's code). There are two things I want to accomplish, both which run into the same problem:</p>
  
  <pre><code>&lt;ion-tabs&gt;
      &lt;ion-tab title="Code" on-select="ace.edit('editor')"&gt;
           &lt;ion-content&gt;
               &lt;div id="editor"&gt;&lt;/div&gt;
           &lt;ion-content&gt;
      &lt;/ion-tab&gt;
      &lt;ion-tab title="Preview" on-select="compileAndPreviewCode()"&gt;
           &lt;ion-content&gt;
               &lt;canvas id="previewCanvas"&gt;&lt;/canvas&gt;
           &lt;ion-content&gt;
      &lt;/ion-tab&gt;
  &lt;/ion-tabs&gt;
  </code></pre>
  
  <p>1) Once the code-edit tab is selected, and AFTER the contents of the tab have been injected to the DOM, I want to run a function that will activate my code editor.  </p>
  
  <ul>
  <li>If I register the function with the on-selected callback, it will get called before the #codeEditor div has been created. </li>
  <li>If I call the function inside a script tag inside the tab content area (that gets created alongside the #editor div) then the script doesn't get executed (see <a href="https://stackoverflow.com/questions/13711735/angular-js-insert-html-with-scripts-that-should-run">See this problem</a>.</li>
  <li>If I include JQuery in my application in an attempt to get such scripts to auto-execute, the ionTabs controller breaks.</li>
  <li>If I try to call the function using a <code>onload</code> event on the editor div, it isn't executed.</li>
  </ul>
  
  <p>2) The same problem applies when the preview tab is selected. I want to compile and inject the code onto the canvas element, but I cannot do this before the canvas element is created.</p>
  
  <p>So, does anyone know how I could call a function <em>after</em> the DOM within an <code>ion-tab</code>'s <code>ion-content</code> is created? </p>