Radio input iside of a repeater is still broken.

167 views
Skip to first unread message

mishabosin

unread,
May 8, 2012, 2:39:03 PM5/8/12
to ang...@googlegroups.com
Hi,

I came across a problem where a radio input's model doesn't appear to bind correctly inside of a repeater.  Here's the fiddle: http://jsfiddle.net/mishabosin/pSZHG/

I found this resolved issue: https://github.com/angular/angular.js/issues/869 in my search for a solution, but it appears to be a slightly different problem.

Please let me know if there's a workaround, or if I should file a bug.

Thanks for an amazing framework!

-Misha

Matthias Andrasch

unread,
May 8, 2012, 3:19:29 PM5/8/12
to ang...@googlegroups.com
Hey!

Api-Docs state the following:

"This directive creates new scope."

I forked your fiddle and used $parent.selectedIndex instead of selectedIndex for ng-model:

Works for me so far, but I don't know if this is how it is supposed to be used regarding ng:repeat.

Cheers,
Matthias

Dan Doyon

unread,
May 8, 2012, 3:18:36 PM5/8/12
to ang...@googlegroups.com
Interesting

I made a little tweak and it works better but there still is a problem. If you click on all the radios, it works first time around, but on subsequent times it stops working -seems the ng-change stops firing.


probably should reopen issue.

--dan



From: mishabosin <misha...@gmail.com>
To: ang...@googlegroups.com
Sent: Tuesday, May 8, 2012 11:39 AM
Subject: [angular.js] Radio input iside of a repeater is still broken.

--
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/-/9sGNUmiSHHwJ.
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.


Johan

unread,
May 8, 2012, 3:35:18 PM5/8/12
to ang...@googlegroups.com
Interesting - I've used radio in repeat but never actually output the value in the same template. However the model has always been set correctly.

Dan Doyon

unread,
May 8, 2012, 3:47:12 PM5/8/12
to ang...@googlegroups.com
+1 on  Mathias' solution and pointing out that ng-repeat does create new scope for each element.




From: Matthias Andrasch <matthias...@googlemail.com>
To: ang...@googlegroups.com
Sent: Tuesday, May 8, 2012 12:19 PM
Subject: [angular.js] Re: Radio input iside of a repeater is still broken.

Hey!

Api-Docs state the following:

"This directive creates new scope."

I forked your fiddle and used $parent.selectedIndex instead of selectedIndex for ng-model:

Works for me so far, but I don't know if this is how it is supposed to be used regarding ng:repeat.

Cheers,
Matthias



On Tuesday, May 8, 2012 8:39:03 PM UTC+2, mishabosin wrote:
Hi,

I came across a problem where a radio input's model doesn't appear to bind correctly inside of a repeater.  Here's the fiddle: http://jsfiddle.net/mishabosin/pSZHG/

I found this resolved issue: https://github.com/ angular/angular.js/issues/869  in my search for a solution, but it appears to be a slightly different problem.

Please let me know if there's a workaround, or if I should file a bug.

Thanks for an amazing framework!

-Misha
--
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/-/xNSJFZTQeJwJ.

Misko Hevery

unread,
May 8, 2012, 10:03:01 PM5/8/12
to ang...@googlegroups.com
In general binding on scope properties is tricky because of scope inheritance. Better to bind on some other object such as controller. See: http://jsfiddle.net/w5TJW/2/

Johan

unread,
May 9, 2012, 1:37:42 AM5/9/12
to ang...@googlegroups.com
Good tip +1 - thanks


On Wednesday, May 9, 2012 2:03:01 PM UTC+12, Misko Hevery wrote:
In general binding on scope properties is tricky because of scope inheritance. Better to bind on some other object such as controller. See: http://jsfiddle.net/w5TJW/2/

On Tue, May 8, 2012 at 12:47 PM, Dan Doyon <dand...@yahoo.com> wrote:
+1 on  Mathias' solution and pointing out that ng-repeat does create new scope for each element.




From: Matthias Andrasch <matthias.andrasch@googlemail.com>

To: ang...@googlegroups.com
Sent: Tuesday, May 8, 2012 12:19 PM
Subject: [angular.js] Re: Radio input iside of a repeater is still broken.
Hey!

Api-Docs state the following:

"This directive creates new scope."

I forked your fiddle and used $parent.selectedIndex instead of selectedIndex for ng-model:

Works for me so far, but I don't know if this is how it is supposed to be used regarding ng:repeat.

Cheers,
Matthias



On Tuesday, May 8, 2012 8:39:03 PM UTC+2, mishabosin wrote:
Hi,

I came across a problem where a radio input's model doesn't appear to bind correctly inside of a repeater.  Here's the fiddle: http://jsfiddle.net/mishabosin/pSZHG/

I found this resolved issue: https://github.com/ angular/angular.js/issues/869  in my search for a solution, but it appears to be a slightly different problem.

Please let me know if there's a workaround, or if I should file a bug.

Thanks for an amazing framework!

-Misha
--
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/-/xNSJFZTQeJwJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/angular?hl=en.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.

Olivier Mourlevat

unread,
Feb 16, 2014, 10:03:30 AM2/16/14
to ang...@googlegroups.com


On Wednesday, May 9, 2012 7:37:42 AM UTC+2, Johan wrote:
Good tip +1 - thanks

On Wednesday, May 9, 2012 2:03:01 PM UTC+12, Misko Hevery wrote:
In general binding on scope properties is tricky because of scope inheritance. Better to bind on some other object such as controller. See: http://jsfiddle.net/w5TJW/2/

On Tue, May 8, 2012 at 12:47 PM, Dan Doyon <dand...@yahoo.com> wrote:
+1 on  Mathias' solution and pointing out that ng-repeat does create new scope for each element.




From: Matthias Andrasch <matthias...@googlemail.com>

To: ang...@googlegroups.com
Sent: Tuesday, May 8, 2012 12:19 PM
Subject: [angular.js] Re: Radio input iside of a repeater is still broken.
Hey!

Api-Docs state the following:

"This directive creates new scope."

I forked your fiddle and used $parent.selectedIndex instead of selectedIndex for ng-model:

Works for me so far, but I don't know if this is how it is supposed to be used regarding ng:repeat.

Cheers,
Matthias



On Tuesday, May 8, 2012 8:39:03 PM UTC+2, mishabosin wrote:
Hi,

I came across a problem where a radio input's model doesn't appear to bind correctly inside of a repeater.  Here's the fiddle: http://jsfiddle.net/mishabosin/pSZHG/

I found this resolved issue: https://github.com/ angular/angular.js/issues/869  in my search for a solution, but it appears to be a slightly different problem.

Please let me know if there's a workaround, or if I should file a bug.

Thanks for an amazing framework!

-Misha
--
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/-/xNSJFZTQeJwJ.
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.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages