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

Commit

Permalink
fix(ngValue): made ngValue to write value attribute to element
Browse files Browse the repository at this point in the history
  • Loading branch information
kirstein authored and IgorMinar committed Jul 11, 2013
1 parent 61fb586 commit 3b89866
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ var ngValueDirective = function() {
} else {
return function(scope, elm, attr) {
scope.$watch(attr.ngValue, function valueWatchAction(value) {
attr.$set('value', value, false);
attr.$set('value', value);
});
};
}
Expand Down
12 changes: 12 additions & 0 deletions test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,18 @@ describe('input', function() {

describe('ngValue', function() {

it('should update the dom "value" property and attribute', function() {
compileInput('<input type="submit" ng-value="value">');

scope.$apply(function() {
scope.value = 'something';
});

expect(inputElm[0].value).toBe('something');
expect(inputElm[0].getAttribute('value')).toBe('something');
});


it('should evaluate and set constant expressions', function() {
compileInput('<input type="radio" ng-model="selected" ng-value="true">' +
'<input type="radio" ng-model="selected" ng-value="false">' +
Expand Down

0 comments on commit 3b89866

Please sign in to comment.