alternative to ng:eval?

303 views
Skip to first unread message

rct...@gmail.com

unread,
Jun 20, 2012, 5:10:36 AM6/20/12
to ang...@googlegroups.com
Hi all,

I know this is about half-a-year late; I'm looking at upgrading from 0.9.19 to 0.10.0.

One of the pain-points I'm currently experiencing is the deprecation/removal of ng:eval. It is being in many places to define "aliases", something like

  <tag ... ng:eval="p = pretty[complex].expression"...>

Initially, I replaced them with ng:init, but that turned out to be the wrong path, since ng:init expressions are not re-evaluated.

A hack I came up with would be to abuse ng:show in this manner:

  <tag ... ng:show="p = pretty[complex].expression; true" ...>

since ng:show gets re-evaluated. But that is clearly inelegant.

I also thought of shifting these assignments into the controller/scope, but sometimes it's not possible, for example when "pretty" (in above code) is an ng-repeat iterator and is not immediately available in the controller/scope.

Suggestions? Thanks.

--
Ray Chuan

Witold Szczerba

unread,
Jun 20, 2012, 11:18:00 AM6/20/12
to ang...@googlegroups.com
Try creating your own 'eval' directive. It should be very simple. You
can see the source code of 'eval' in 0.9.x branch and try to recreate
such a directive in 0.10.x or 1.0 the same way as you create other
ones.

Regards,
Witold Szczerba
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/angular/-/N10CvHPv5UcJ.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to
> angular+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/angular?hl=en.
Reply all
Reply to author
Forward
0 new messages