Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8840345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:26:40+00:00 2026-06-14T10:26:40+00:00

I would like to use the same HTML template in 3 places, just each

  • 0

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.

Is there a way to pass a model to the ngInclude?

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.

<pane title="{{projectSummary.ProjectResults.DisplayName}}">
    <h2>{{projectSummary.ProjectResults.DisplayName}}</h2>
    <ng-include src="'Partials/SummaryDetails.html'" init-variable="{'detailsObject': projectSummary.ProjectResults}"></ng-include>
</pane>

<pane  title="Documents" header="true"></pane>

<pane ng-repeat="document in projectSummary.DocumentResults" title="{{document.DisplayName}}">
    <h2>{{document.DisplayName}}</h2>
    <ng-include src="'Partials/SummaryDetails.html'" add-variable="{'detailsObject': document}"></ng-include>
</pane>

<pane ng-repeat="header in [1]" title="Languages" header="true"></pane>

<pane ng-repeat="language in projectSummary.ResultsByLanguagePairs" title="{{language.DisplayName}}">
    <h2>{{document.DisplayName}}</h2>
    <ng-include src="'Partials/SummaryDetails.html'" add-variable="{'detailsObject': language}"></ng-include>
</pane>

If I took a bad approach with using ng-include, is there something else I should try?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:26:42+00:00Added an answer on June 14, 2026 at 10:26 am

    NOTE: this is not my original answer but this is how I’d do this after using angular for a bit.

    I would create a directive with the html template as the markup passing in the dynamic data to the directive as seen in this fiddle.

    Steps/notes for this example:

    1. Define a directive with markup in the templateUrl and attribute(s) used to pass data into the directive (named type in this example).
    2. Use the directive data in the template (named type in this example).
    3. When using the directive in the markup make sure you pass in the data from the controller scope to the directive (<address-form type="billing"></address-form> (where billing is accessing an object on the controller scope).
    4. Note that when defining a directive the name is camel cased but when used in the markup it is lower case dash delimited (ie it’s named addressForm in the js but address-form in the html). More info on this can be found in the angular docs here.

    Here is the js:

    var myApp = angular.module('myApp',[]);
    
    angular.module('myApp').directive('addressForm', function() {
        return {
            restrict: 'E',
            templateUrl: 'partials/addressform.html', // markup for template
            scope: {
                type: '=' // allows data to be passed into directive from controller scope
            }
        };
    });
    
    angular.module('myApp').controller('MyCtrl', function($scope) {
        // sample objects in the controller scope that gets passed to the directive
        $scope.billing = { type: 'billing type', value: 'abc' };
        $scope.delivery = { type: 'delivery type', value: 'def' };
    });
    

    With markup:

    <div ng-controller="MyCtrl">
        <address-form type="billing"></address-form>
        <address-form type="delivery"></address-form>
    </div>
    

    ORIGINAL ANSWER (which is completely different than using a directive BTW).

    Note: The fiddle from my original answer below doesn’t appear to work anymore due to an error (but keeping it here in case it is still useful)

    There was a discussion about this on the Google Group you can see it here.

    It looks like this functionality is not supported out of the box but you can use Brice’s patch as described in this post.

    Here is the sample code from his jsfiddle:

    <script id="partials/addressform.html" type="text/ng-template">
        partial of type {{type}}<br>
    </script>
    
    <div ng-controller="MyCtrl">
      <ng-include src="'partials/addressform.html'" onInclude="type='billing'"></ng-include>
      <ng-include src="'partials/addressform.html'" onLoad="type='delivery'"></ng-include>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use the form_for helper multiple times for the same model
I would like to use the same code for copying files to an FTP
I would like to be able to use the same Session variable when transferring
I would like to use both of these library on the same page but
I would like to be able to use the same drawable to represent both:
I would like to use django template for e-mail sending. But I should have
I want to use the same template to display records from different models in
I Have this function, I would like to use the same function for 3
Is it possible to use a different HTML layout for the same XSLT stylesheet?
I have an array of Integers in Java, I would like use only a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.