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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:22:24+00:00 2026-06-17T17:22:24+00:00

I want to render different html templates (bound to a model) within ng-repeat. <div

  • 0

I want to render different html templates (bound to a model) within ng-repeat.

<div ng-repeat="section in sections | filter:unansweredSections">

    // Here i want something like
    if section == children
        render div#children
    else if section == work
        render div#work

</div>


<div style="display:none" id="children">
    // i want to bind this to sections info
    <input ng-model="???.totalChildren" />
</div>


<div style="display:none" id="work">
    // i want to bind this to sections info
    <input ng-model="???.work1" />
    <input ng-model="???.work2" />
</div>

Now in the last two divs I actually want the inputs to be bound to parameters of concrete sections.

My model looks like this:

$scope.sections = [
    {"name" : "children","totalChildren" : 0},
    {"name" : "work","work1" : "","work2" : ""}
]

I could make it an object instead of an array

$scope.sections = {
    "children"  : {"totalChildren" : 0},
    "work"      : {"work1" : "","work2" : ""}
}

And then easily bind to it

<div style="display:none" id="children">
    <input ng-model="sections.childern.totalChildren" />
</div>

But then I can’t use filter and ordering on it.

  • 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-17T17:22:25+00:00Added an answer on June 17, 2026 at 5:22 pm

    There are many ways of doing this.

    1. You can use ng-show (and/or ng-hide) to act like if’s and show only the elements corresponding to each model (child or work). The problem of this approach is that it will just hide the elements from the oposing model and not remove them, which increases the DOM unnecessarily.

      <div class="work" ng-show={{isWork()}}>work template</div>
      <div class="child" ng-show={{isChild()}}>child template</div>
      
    2. Use a directive like Angular-UI ui-if (this will avoid the problem of maintaing unnecessary DOM elements).

      <div class="work" ui-if={{isWork()}}>work template</div>
      <div class="child" ui-if={{isChild()}}>child template</div>
      
    3. Create a custom directive to render your own templates for each model, like in this example fiddle: http://jsfiddle.net/bmleite/kbxJm/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to render for facebook bot special data. I have og.html.erb <!DOCTYPE html><html><head>
I want to render equations to PNG files and embed them in the HTML
I want to override the templates/admin/change_list_results.html and templates/admin/change_list.html templates for just one of my
In my rails app, I want to render certain pages within a lightbox but
I want to render the partial view using ajax. When I submit the button,
I want to render a profile user container that contains a list of labels
i want to render one of these sets of views: head body-$id1 foot OR
I want to render an object from my controller to a jQuery callback function.
I want to render same template on one page which should display the value
Well I want to render a self closing tag say <img> tag like this

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.