Updating ng-options dynamically in a select

3,990 views
Skip to first unread message

Paul Knox-Kennedy

unread,
Jun 14, 2013, 11:40:17 AM6/14/13
to ang...@googlegroups.com
I have an array of objects, that need to be able to reference each other. This is all working, unless I update the name of one object that is currently referenced. For example: http://jsfiddle.net/uLdmH/2/. This is all working, unless you change the name of a "block" - change "One" to "OneA" and the select for the second block loses its reference.
Any ideas?
Cheers
Paul

Paul Knox-Kennedy

unread,
Jun 14, 2013, 11:41:09 AM6/14/13
to ang...@googlegroups.com
Noter that, if neither select references "One" when you change its name, everything works.

Lulzim Bilali

unread,
Jun 14, 2013, 12:52:55 PM6/14/13
to ang...@googlegroups.com
Hi Paul,

I changed a bit your fiddle and now it works. http://jsfiddle.net/uLdmH/3/

Basically I added an id to your objects and than used the id to reference, so when the name is changes still Angular can reference the object otherwise the object "One" does after you change the name to let say "One 1" so there si no object to be referenced.

hope that helps

Paul Knox-Kennedy

unread,
Jun 14, 2013, 1:50:32 PM6/14/13
to ang...@googlegroups.com
Wonderfully simple change!. Thanks

Grant Rettke

unread,
Jun 15, 2013, 1:19:49 PM6/15/13
to ang...@googlegroups.com
On Fri, Jun 14, 2013 at 12:50 PM, Paul Knox-Kennedy
<paul.kno...@gmail.com> wrote:
> Wonderfully simple change!. Thanks

Most of the time it makes sense to have a separate notion of data
identify from the "display name".
Reply all
Reply to author
Forward
0 new messages