How to coopt ng-repeat ?

104 views
Skip to first unread message

Gary M

unread,
Oct 23, 2014, 10:09:49 PM10/23/14
to ang...@googlegroups.com
Hi,

I'm trying to transparently place an attribute into elements created by ng-repeat.  I have existing code that cannot be changed, some built by libraries by others..

I don't want to additional attributes via ng-repeat-start which will require other code using ng-repeat to be modified.

thx
-g

Gary M

unread,
Oct 24, 2014, 4:25:05 PM10/24/14
to ang...@googlegroups.com
It looks like this can't be done  without adding the attribute or chaining the ng-repeat directive and creating a new directive.

Sounds like a feature request. .

Gary M

unread,
Oct 24, 2014, 4:52:12 PM10/24/14
to ang...@googlegroups.com


On Thursday, October 23, 2014 8:09:49 PM UTC-6, Gary M wrote:

Sander Elias

unread,
Oct 25, 2014, 1:40:23 AM10/25/14
to ang...@googlegroups.com
Hi Gary,

I highly doubt that this is something that fits inclusion into AngularJS itself.
But there is a lot of information missing to me, like:
  1. What kind of attribute you want to inject. 
  2. At what moment you want to add this? (before or after the repeat runs?)
  3. Is there additional (angular) processing needed on this attribute?
  4. Do you have at least access to the model(s) driving the code you can't change?
What you are asking is possible, but the solution is highly dependent on the answers on the
above questions.

Regards
Sander


Gary M

unread,
Oct 25, 2014, 6:49:42 AM10/25/14
to ang...@googlegroups.com
Hi Sanders,

Thank you for replying.. 

  • What kind of attribute you want to inject. 
[gm]  I'd like to add an attribute which will indicate $index or the data object, but css is also an option

  • At what moment you want to add this? (before or after the repeat runs?)
[gm]  I would like to add this before the repeat runs. I'm assuming the scope context is established prior to running.  

  • Is there additional (angular) processing needed on this attribute?
[gm] No, not outside of the repeat loop state. eg $index. 

  • Do you have at least access to the model(s) driving the code you can't change?
[gm]  Sometimes yes, other times no.. So I'm proceeding  as I will not. I can transverse parent elements to find the data via ng-model.

I'm writing a generalized editor framework which will be able to easily integrate jquery, highcharts, and other graphical (svg) editors bridging  the gap between angularjs and other libraries.For example, I wanted to use jquery draggable, droppable, and sortable with angularjs. The angularjs directives provided by other developers do not interoperate. A framework will help remediate  this issue and accelerate development of foreign libraries into angularjs.. 


b/r
gary



--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/ZNiEC50si2o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Sander Elias

unread,
Oct 25, 2014, 7:26:21 AM10/25/14
to ang...@googlegroups.com
Hi Gary,

Ah, now I get the picture a bit more clearly. 
I have an additional couple of questions now ;)

1. this is clearly still a concept (correct me if I'm wrong!). When are you planning for release?
2. Are you aware that this concept will not work with Angular 2? (not in it's current implementation/concept)

I like you idea. Perhaps you should take another look at the way you want to interface to the current stuff.
What you want is indeed possible, although not not easy to realize. Also there will be lots of edge-cases to
be aware off. 

Regards
Sander

Sander Elias

unread,
Oct 25, 2014, 7:37:38 AM10/25/14
to ang...@googlegroups.com
Hi Gary,

I just realized I need to add some info to my point 2.
The reason it will not work with Angular 2 is because most, if not all
the things you want to do will be already taken care of in there.

Things to consider, in Angular 2.0 there will NOT be:
  • scope.apply
  • (ng-)controllers 
  • angular.module
  • directive definition objects
  • jQlite (only direct DOM manipulation)
The last point is very important, you may use jQuery allongside Angular 2 if you want. But you don't need to!
So, if you need a short term solution, go ahead, and create it. Again, it will not be easy.
But you might want to reconsider this.

Regards
Sander

Gary M

unread,
Oct 25, 2014, 8:38:04 AM10/25/14
to ang...@googlegroups.com
Hi Sanders,

Yes, this is the concept, I'm designing right now..I'm just finishing the dispatch broker. The broker serves the same purpose as Traceur decorator and dependency injection, but permits dynamic shuffling of chained function AND event dispatching execution order. 

I still need to create a github project, I like to have the code cleaned up before letting others see my dirty laundry 

I'm planning a release angular 1.x as soon as I get pieces complete.. Since this is unsponsored work, I'm working on it in my free time.. Schedule is a bit tough to determine, but soon

I'm sure there are going to be plenty of edge cases.. That's why I wanted something simple at first. I'm hoping to get 90% case coverage with 10% effort ?

I haven't really explored angular 2.0, I'm not on the inside track, so I'll have to wait until its solid.. I believe this project will be significantly easier with 2.x and will require a ground up redesign.

I do like the annotation driven compiler, specifically the ability to inject arbitrary annotations to specific objects.  Annotations support becomes increasingly important in interpreted languages to easily create new features. I do recommend compile on the fly to reconfigure execution orders as lazy and on-demand modules are required. The documentation alludes to this, but its unclear whether the hierarchy just supports lazy compile or dynamic/modifiable configuration   . Also, I see nothing wrong with the global state, other than static configuration.  

cheers,
gary






--

Sander Elias

unread,
Oct 27, 2014, 5:16:09 AM10/27/14
to ang...@googlegroups.com
Hi Garys

I'm sure there are going to be plenty of edge cases.. That's why I wanted something simple at first. I'm hoping to get 90% case coverage with 10% effort ?
I'm afraid that in this case the numbers will be more like 75% coverage with 40% effort. But don't let me talk you out of it. If you get this running it will be an enormous help to 
a fair number of developers.

I haven't really explored angular 2.0, I'm not on the inside track, so I'll have to wait until its solid.. I believe this project will be significantly easier with 2.x and will require a ground up redesign.
Well, I keep my eye on 2.x and yes and yes ;)
 
I do like the annotation driven compiler, specifically the ability to inject arbitrary annotations to specific objects.  Annotations support becomes increasingly important in interpreted languages to easily create new features. I do recommend compile on the fly to reconfigure execution orders as lazy and on-demand modules are required. The documentation alludes to this, but its unclear whether the hierarchy just supports lazy compile or dynamic/modifiable configuration   . Also, I see nothing wrong with the global state, other than static configuration.  
Hi, If you are talking about the annotations from 2.0, those are part of ATscript. ATscript compiles to  ES5. As it is an language that does compiling you can't use in the browser to do on the fly compilation(not in a well performing way anyhow)
Lazy loading will be supported, but this will be largely part of the new router. And of course when ES6 modules become readily available, those will be usable too.

Regards
Sander

Gary M

unread,
Oct 27, 2014, 6:48:57 AM10/27/14
to ang...@googlegroups.com
Hi Sander

I'm sure there are going to be plenty of edge cases.. That's why I wanted something simple at first. I'm hoping to get 90% case coverage with 10% effort ?
I'm afraid that in this case the numbers will be more like 75% coverage with 40% effort. But don't let me talk you out of it. If you get this running it will be an enormous help to 
a fair number of developers.

Well, we can see how it goes.. . If I append the inject property defined in scope to $attr in ng-repeat's compile, it looks like it should work fairly cleanly. ng-repeat evaluates the $attrs properly, so if I'm careful to keep it simple, it should work.

I haven't really explored angular 2.0, I'm not on the inside track, so I'll have to wait until its solid.. I believe this project will be significantly easier with 2.x and will require a ground up redesign.
Well, I keep my eye on 2.x and yes and yes ;)
 
I do like the annotation driven compiler, specifically the ability to inject arbitrary annotations to specific objects.  Annotations support becomes increasingly important in interpreted languages to easily create new features. I do recommend compile on the fly to reconfigure execution orders as lazy and on-demand modules are required. The documentation alludes to this, but its unclear whether the hierarchy just supports lazy compile or dynamic/modifiable configuration   . Also, I see nothing wrong with the global state, other than static configuration.  
Hi, If you are talking about the annotations from 2.0, those are part of ATscript. ATscript compiles to  ES5. As it is an language that does compiling you can't use in the browser to do on the fly compilation(not in a well performing way anyhow)
 
If the compile is done in the background in a private node which is then moved to the proper location in the DOM, it may work fairly transparently to the user. A wrapper around the compiler could perform those operations..
 
Lazy loading will be supported, but this will be largely part of the new router. And of course when ES6 modules become readily available, those will be usable too.

Hmmm interesting  

b/r gary
Reply all
Reply to author
Forward
0 new messages