Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to specify model to a ngInclude directive in AngularJS?
    primarykey
    data
    text
    <p>I would like to use the same HTML template in 3 places, just each time with a different model. I know I can access the variables from the template, but there names will be different.</p> <p>Is there a way to pass a model to the ngInclude?</p> <p>This is what I would like to achieve, of course the attribute add-variable does not work now. Then in my included template, I would acces the detailsObject and its properties.</p> <pre><code>&lt;pane title="{{projectSummary.ProjectResults.DisplayName}}"&gt; &lt;h2&gt;{{projectSummary.ProjectResults.DisplayName}}&lt;/h2&gt; &lt;ng-include src="'Partials/SummaryDetails.html'" init-variable="{'detailsObject': projectSummary.ProjectResults}"&gt;&lt;/ng-include&gt; &lt;/pane&gt; &lt;pane title="Documents" header="true"&gt;&lt;/pane&gt; &lt;pane ng-repeat="document in projectSummary.DocumentResults" title="{{document.DisplayName}}"&gt; &lt;h2&gt;{{document.DisplayName}}&lt;/h2&gt; &lt;ng-include src="'Partials/SummaryDetails.html'" add-variable="{'detailsObject': document}"&gt;&lt;/ng-include&gt; &lt;/pane&gt; &lt;pane ng-repeat="header in [1]" title="Languages" header="true"&gt;&lt;/pane&gt; &lt;pane ng-repeat="language in projectSummary.ResultsByLanguagePairs" title="{{language.DisplayName}}"&gt; &lt;h2&gt;{{document.DisplayName}}&lt;/h2&gt; &lt;ng-include src="'Partials/SummaryDetails.html'" add-variable="{'detailsObject': language}"&gt;&lt;/ng-include&gt; &lt;/pane&gt; </code></pre> <p>If I took a bad approach with using ng-include, is there something else I should try?</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.
 

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