Angularjs custom radio button directive

1,962 views
Skip to first unread message

Alan Löffler

unread,
Dec 22, 2013, 12:25:11 PM12/22/13
to ang...@googlegroups.com
Hi, I'm trying to make a custom radio button with a directive.
The problem is that when I use in the same scope more than one group of radios (like two groups with two different models), the second group updates the model of the first group.
I know that there's something wrong in my directive, I need to say to the directive to use an own scope, but don't know how.


I really appreciate some help!
Thanks.

Daniel Tabuenca

unread,
Dec 23, 2013, 3:10:46 AM12/23/13
to ang...@googlegroups.com

Your problem is more of an html+css problem than an angular problem.

You are generating radio inputs and labels using {{value}} as the id. You should not have duplicate element ids in a page, especially when using html <label for='id'>.

You need to make sure you generate unique ids for things. I’ve modified your example to us the value of the ng-module attribute along with the value to generate an id:

http://jsfiddle.net/NZ8EX/5/

Anaida Herry

unread,
Jul 11, 2014, 11:23:13 AM7/11/14
to ang...@googlegroups.com
I want the same functionality but if I click on label the radio should get selected.

Can anyone help me ?

Thanks,

Gopinath Pandian MCA

unread,
Aug 25, 2016, 2:07:34 AM8/25/16
to AngularJS, ama...@gmail.com
HI Anaida Herry,,
Daniel Tabuenca  has shared the solution.. it will help u sure.. 
thank you Daniel.
Reply all
Reply to author
Forward
0 new messages