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

Commit ade6c45

Browse files
committed
feat(input.radio): Allow value attribute to be interpolated
1 parent 9eafd10 commit ade6c45

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/directive/input.js

+2
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ function radioInputType(scope, element, attr, ctrl) {
560560
var value = attr.value;
561561
element[0].checked = isDefined(value) && (value == ctrl.$viewValue);
562562
};
563+
564+
attr.$observe('value', ctrl.$render);
563565
}
564566

565567
function checkboxInputType(scope, element, attr, ctrl) {

test/directive/inputSpec.js

+17-5
Original file line numberDiff line numberDiff line change
@@ -720,18 +720,30 @@ describe('input', function() {
720720
});
721721

722722

723-
// TODO(vojta): change interpolate ?
724-
xit('should allow {{expr}} as value', function() {
723+
it('should allow {{expr}} as value', function() {
725724
scope.some = 11;
726725
compileInput(
727726
'<input type="radio" ng-model="value" value="{{some}}" />' +
728727
'<input type="radio" ng-model="value" value="{{other}}" />');
729728

730-
browserTrigger(inputElm[0]);
731-
expect(scope.value).toBe(true);
729+
scope.$apply(function() {
730+
scope.value = 'blue';
731+
scope.some = 'blue';
732+
scope.other = 'red';
733+
});
734+
735+
expect(inputElm[0].checked).toBe(true);
736+
expect(inputElm[1].checked).toBe(false);
732737

733738
browserTrigger(inputElm[1]);
734-
expect(scope.value).toBe(false);
739+
expect(scope.value).toBe('red');
740+
741+
scope.$apply(function() {
742+
scope.other = 'non-red';
743+
});
744+
745+
expect(inputElm[0].checked).toBe(false);
746+
expect(inputElm[1].checked).toBe(false);
735747
});
736748
});
737749

0 commit comments

Comments
 (0)