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

Commit

Permalink
feat(input.radio): Allow value attribute to be interpolated
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Mar 20, 2012
1 parent 9eafd10 commit ade6c45
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ function radioInputType(scope, element, attr, ctrl) {
var value = attr.value;
element[0].checked = isDefined(value) && (value == ctrl.$viewValue);
};

attr.$observe('value', ctrl.$render);
}

function checkboxInputType(scope, element, attr, ctrl) {
Expand Down
22 changes: 17 additions & 5 deletions test/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,18 +720,30 @@ describe('input', function() {
});


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

browserTrigger(inputElm[0]);
expect(scope.value).toBe(true);
scope.$apply(function() {
scope.value = 'blue';
scope.some = 'blue';
scope.other = 'red';
});

expect(inputElm[0].checked).toBe(true);
expect(inputElm[1].checked).toBe(false);

browserTrigger(inputElm[1]);
expect(scope.value).toBe(false);
expect(scope.value).toBe('red');

scope.$apply(function() {
scope.other = 'non-red';
});

expect(inputElm[0].checked).toBe(false);
expect(inputElm[1].checked).toBe(false);
});
});

Expand Down

0 comments on commit ade6c45

Please sign in to comment.