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 8637963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:36:22+00:00 2026-06-12T10:36:22+00:00

I am relatively new to AngularJS and would like to know how feasible it

  • 0

I am relatively new to AngularJS and would like to know how feasible it is to pull in partial templates dynamically. Consider this abstracted (and simplified for this example) module. This itself would be a partial template that will be reused throughout the application.

Partial Module Markup

<div class="module">
    <h2 class="module-title">{{module.title}}</h2>

    <div class="module-content">
        {{module.content}}
    </div>

</div>

After fetching some data client side, I may wish for module.content to be a simple string of text, no problems there. What would be useful is if I could dynamically insert other partial templates into module.content based on the data I’m working with. Say for example in my response I have a list of headlines I wish to display, is is possible to pull in a partial template that handles headlines? And in another spot, module.content could be a partial template that handles a gallery of images.

Any input or direction would be greatly appreciated!

  • 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-12T10:36:24+00:00Added an answer on June 12, 2026 at 10:36 am

    There are a couple approaches available to you.

    Your best bet is to add your own directive. Expanding on your example:

    module.directive('myModule', function() {
      return {
        restrict: 'A',
        scope : {
          title : '@'
        },
        templateUrl : '/partial/module.html',
        transclude : true
      };
    });
    

    We’ll use transclusion to make the contents more flexible. Now the partial:

    <div class="module">
      <h2 class="module-title">{{title}}</h2>
    
      <div class="module-content" ng-transclude></div>
    </div>
    

    With this directive installed, you can use the following HTML:

    <div my-module title="{{module.title}}">
      {{module.content}}
    </div>
    

    Another option is to use the ng-include directive. This is a simple transclusion of a partial, the difference being that the transcluded partial lives in the same scope as the context it was included in.

    <div ng-include="module.partialUrl"></div>
    

    In the above case, Angular will transclude the partial at the URL at $scope.module.partialUrl. (Edit: this means you can dynamically substitute out UIs by replacing the scope variable used by ngInclude. Awesome, right?)

    If you’re just reusing the same partial to avoid repetitive code, then simply surround the URL in single quotes:

    <div ng-include="'/partial/foo.html'"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Relatively new to Python.. I would like to know how to check if a
im relatively new to ROR, and would like some help with the following code.
I'm relatively new to Akka & Scala, but I would like to use Akka
relatively new programmer here. Look at the two classes defined below. I'd like to
Hi I'm relatively new to Android programming but I would be grateful of some
I am relatively new to c# and the event handling concept. Inside this function
I am a relatively new programmer so this may be a really simple question
Relatively new to mySQL so this is probably an easy one: I have a
Relatively new to using database and for some reason I can't get this 'execute'
Relatively new to Cocoa here. This question is about NSFileHandle, but I got 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.