Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

feat($compile): support directive virtual groups #2783

Merged
merged 1 commit into from
May 29, 2013

Conversation

mhevery
Copy link
Contributor

@mhevery mhevery commented May 24, 2013

By appending X-start and X-end to a directive it is now possible
to have the directive act on a group of elements.

It is now possible to iterate over multiple elements like so:

<table>
  <tr ng-repeat-start="item in list">I get repeated</tr>
  <tr ng-repeat-end>I also get repeated</tr>
</table>

@@ -573,6 +587,47 @@ function $CompileProvider($provide) {
return directives;
}

/**
* Given a node witch a X-start it collects all of the siblings until it find X-end.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "witch a" -> "with an" or "which has an"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@lrlopez
Copy link
Contributor

lrlopez commented May 25, 2013

Cool! Just one comment: It may be necessary to state that this introduces a breaking change as any previous directive that ended with start won't work now without changes.

By appending  directive-start and directive-end to a
directive it is now possible to have the directive
act on a group of elements.

It is now possible to iterate over multiple elements like so:

<table>
  <tr ng-repeat-start="item in list">I get repeated</tr>
  <tr ng-repeat-end>I also get repeated</tr>
</table>
@mhevery mhevery merged commit e46100f into angular:master May 29, 2013
@gevgeny
Copy link

gevgeny commented Jun 2, 2013

I have tried to run this example but got the error:
TypeError: Object #<Text> has no method 'hasAttribute' at groupScan (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:4730:20) at applyDirectivesToNode (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:4796:26) at compileNodes (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:4563:15) at compileNodes (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:4568:15) at compileNodes (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:4568:15) at compileNodes (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:4568:15) at compileNodes (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:4568:15) at compileNodes (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:4568:15) at compile (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:4505:29) at resumeBootstrapInternal (http://localhost:8889/examples/market-stats3/js/dependencies/angular.1.1.6-b6a0777.js:1009:11)

See details here: http://stackoverflow.com/questions/10457833/how-would-i-render-a-dynamic-definition-list-using-angular/16808545#16808545

@aleksabl
Copy link

aleksabl commented Jun 3, 2013

I've made a fix for this inn pull request #2859 .

@cdmckay
Copy link

cdmckay commented Jun 11, 2013

Wouldn't it make more sense to have a ngGroup directive that self-destructs after being added?

<table>
  <ng-group ng-repeat="item in list">
    <tr>I get repeated</tr>
    <tr>I also get repeated</tr>  
  </ng-group>
</table>

When ng-group renders, it always removes itself and adds it's children to its parent element.

rodyhaddad added a commit to rodyhaddad/angular.js that referenced this pull request Aug 6, 2013
I've built on the work of angular#2783 to make multi-elements possible in all
directive decralation styles.
Basically angular#2783 was limited to directives declared via attributes.
With this commit, appending X-start and X-end would work
in Comments, Attributes, ClassNames and ElementNames
```html
<table>
  <!-- directive: ng-repeat-start item in list -->
    <tr>If ngRepeat's 'restrict' get changed to include 'M'</tr>
    <tr>I get repeated</tr>
  <!-- ng-repeat-end -->
</table>
```
rodyhaddad added a commit to rodyhaddad/angular.js that referenced this pull request Aug 14, 2013
I've built on the work of angular#2783 to make multi-elements possible in all
directive decralation styles.
Basically angular#2783 was limited to directives declared via attributes.
With this commit, appending X-start and X-end would work
in Comments, Attributes, ClassNames and ElementNames
```html
<table>
  <!-- directive: ng-repeat-start item in list -->
    <tr>If ngRepeat's 'restrict' get changed to include 'M'</tr>
    <tr>I get repeated</tr>
  <!-- ng-repeat-end -->
</table>
```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.