Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 35ca4fc

Browse files
committed
radio now works with repeaters
1 parent 5bd23fd commit 35ca4fc

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

scenario/widgets.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<script type="text/javascript" src="../src/angular-bootstrap.js#autobind"></script>
66
</head>
77
<body ng-init="$window.$scope = $root">
8-
<table>
8+
<table ng-repeat="i in [0, 1]">
99
<tr>
1010
<th>Description</th>
1111
<th>Test</th>

src/Scope.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function errorHandlerFor(element, error) {
8484
elementError(element, NG_EXCEPTION, isDefined(error) ? toJson(error) : error);
8585
}
8686

87+
var scopeId = 0;
8788
function createScope(parent, Class) {
8889
function Parent(){}
8990
function API(){}
@@ -103,6 +104,7 @@ function createScope(parent, Class) {
103104

104105
extend(api, {
105106
'this': instance,
107+
$id: (scopeId++),
106108
$parent: parent,
107109
$bind: bind(instance, bind, instance),
108110
$get: bind(instance, getter, instance),

src/Widgets.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ function initWidgetValue(initValue) {
111111
};
112112
}
113113

114-
function radioInit(model, view) {
115-
var modelValue = model.get(), viewValue = view.get();
114+
function radioInit(model, view, element) {
115+
var modelValue = model.get(), viewValue = view.get(), input = element[0];
116+
input.name = this.$id + '@' + input.name;
116117
if (isUndefined(modelValue)) model.set(null);
117118
if (viewValue != null) model.set(viewValue);
118119
}
@@ -123,7 +124,7 @@ function inputWidget(events, modelAccessor, viewAccessor, initFn) {
123124
model = modelAccessor(scope, element),
124125
view = viewAccessor(scope, element),
125126
action = element.attr('ng-change') || '';
126-
initFn(model, view);
127+
initFn.call(scope, model, view, element);
127128
this.$eval(element.attr('ng-init')||'');
128129
element.bind(events, function(){
129130
model.set(view.get());

test/widgetsSpec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ describe("input widget", function(){
130130
'</div>');
131131
var a = element[0].childNodes[0];
132132
var b = element[0].childNodes[1];
133+
expect(b.name.split('@')[1]).toEqual('chose');
133134
expect(scope.chose).toEqual('B');
134135
scope.chose = 'A';
135136
scope.$eval();

0 commit comments

Comments
 (0)