Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading with ngInclude into multiple DOM locations
    primarykey
    data
    text
    <p>I'm building an app in AngularJS where the user creates some app state, then there are a number of different ways to render it. (For a lame example, let's say they're going to enter three numbers, and then they can choose to render them into a line chart or a pie chart.)</p> <p>Each rendering type lives in a different HTML file, and I'm letting the user choose a renderer with a &lt;select&gt; which drives the src for an ng-include to load the different renderers. This works fine, so far.</p> <p>Now, some rendering modes have additional controls; for example, the pie chart might have a "3D" checkbox. Different renderers will have entirely distinct controls. So I want these included files to also create controls for customizing their presentation.</p> <p>Here's my question: how do I load a single file and let it create its additional control in one spot in the DOM while putting its main content into another spot in the DOM? The additional control cannot appear adjacent to the rendered content in the DOM: it goes in an entirely different location.</p> <p>Here is an example: <a href="http://plnkr.co/edit/1RXVVu?p=preview" rel="nofollow">http://plnkr.co/edit/1RXVVu?p=preview</a>. I would like, in a.html and b.html, to be able to instantiate their popup controls in the DOM above the &lt;hr&gt;, while having their textual content below the &lt;hr&gt;. (While it would be possible in the example to just put an hr tag in each of a.html and b.html, the real DOM structure is much more complex and doesn't afford that.)</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload