Skip to content

Signal Through the Noise

Honest takes on code, AI, and what actually works

Menu
  • Home
  • My Story
  • Experience
  • Services
  • Contacts
Menu

AngularJS directive multiple element

Posted on November 21, 2014 by ivan.turkovic

How to get AngularJS directive multiple element

You probably know there exists opening ng-repeat-start and finishing directive ng-repeat-end like:

<ul>
 <li ng-repeat-start="user in users">
   {{user.firstName}}
 </li>
 <li ng-repeat-end>
   {{user.firstName}}
 </li>
</ul>

You would think it is a specially made directive that works that way but actually it is not. It is part of any directive so you can use it inside your too. When you create new directory and inside you factory function you need to return an object with multiElement options set to true. This way it will behave same as ngRepeat directive over multiple non nested fields. Small excerpt from ngRepeat.js file denoting this:

var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
  ...
  return {
    restrict: 'A',
    <strong>multiElement: true,</strong>
    transclude: 'element',
    priority: 1000,
    terminal: true,
    ...
   }
}];

From native angularJS directive there are few more directives that support multi element spanning. They are ngIf, ngShow, ngHide and ngSwitch. So by adding multiElement to your custom directive you can make to transclude over angularjs directive multiple elements at the same time. This also comes handy because you can do nesting of multiple elements if they are contained inside another one.

2 thoughts on “AngularJS directive multiple element”

  1. akash sinha says:
    May 2, 2015 at 4:34 pm

    any example please, for how and where to use this property??

  2. thorsson says:
    May 2, 2015 at 4:40 pm

    @disqus_DpH5LVDFS6:disqus I usually use it for rendering two consecutive divs over a collection where divs are mutually exclusive so on specific actions it switches to another one. Like having a hover action to show another div and doing rotation between them for example.

Comments are closed.

Recent Posts

  • The Training Data Paradox: What Happens When AI Replaces the Engineers Who Trained It
  • AI Made Writing Code Easier. It Made Being an Engineer Harder.
  • The First 1,000 Lines Determine the Next 100,000 in AI Coding
  • How to Make Your Website Agent-Ready With WebMCP: A Practical Guide
  • Coding Is Changing. Software Engineering Is Not Going Anywhere.

TOP 3% TALENT

Vetted by Hire me
PhoneGap Essentials by Ivan Turkovic

PhoneGap Essentials
by Ivan Turkovic

  • Instagram
  • Facebook
  • GitHub
  • LinkedIn

Recent Comments

  • AI Made Writing Code Easier. It Made Being an Engineer Harder - CodeGurus - CodeGurus on AI Made Writing Code Easier. It Made Being an Engineer Harder.
  • The Training Data Paradox: AI Replacing Engineers Who Built It on Contact Me
  • How to Make Your Website Agent-Ready With WebMCP on WebMCP Is Coming: How AI Agents Will Reshape the Web
  • Coding Is Changing. Software Engineering Isn't Obsolete. on Contact Me
  • The "Build It Yourself" Trap: AI Tooling vs. Core Product on Contact Me

Archives

  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • May 2025
  • April 2025
  • March 2025
  • January 2021
  • April 2015
  • November 2014
  • October 2014
  • June 2014
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • April 2012
  • October 2011
  • September 2011
  • June 2011
  • December 2010

Categories

  • ADD Methodology
  • AI
  • AI development
  • AI-Driven Development
  • AngularJS
  • Artificial Intelligence
  • Behavior-Driven Development
  • Best Practices
  • blockchain
  • Business Strategy
  • Career Development
  • Code Integration
  • Code Review
  • Critical Thinking
  • development
  • Development Methodology
  • ebook
  • Introduction
  • leadership
  • Legacy Code
  • mac os
  • personal
  • personal development
  • presentation
  • productivity
  • Quality Assurance
  • Refactoring
  • Requirements
  • ruby
  • ruby on rails
  • sinatra
  • Software Development
  • Software Engineering
  • Software Testing
  • Specification
  • start
  • startup
  • success
  • Uncategorized
  • WebMCP

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2026 Signal Through the Noise | Powered by Superbs Personal Blog theme