fix(ngValue): made ngValue to write value attribute to element

This commit is contained in:
Mikk Kirstein 2013-05-14 20:14:06 +03:00 committed by Igor Minar
parent 52d6a59902
commit 09a1e7af12
2 changed files with 13 additions and 1 deletions

View file

@ -1335,7 +1335,7 @@ var ngValueDirective = function() {
} else { } else {
return function(scope, elm, attr) { return function(scope, elm, attr) {
scope.$watch(attr.ngValue, function valueWatchAction(value) { scope.$watch(attr.ngValue, function valueWatchAction(value) {
attr.$set('value', value, false); attr.$set('value', value);
}); });
}; };
} }

View file

@ -1136,6 +1136,18 @@ describe('input', function() {
describe('ngValue', 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() { it('should evaluate and set constant expressions', function() {
compileInput('<input type="radio" ng-model="selected" ng-value="true">' + compileInput('<input type="radio" ng-model="selected" ng-value="true">' +
'<input type="radio" ng-model="selected" ng-value="false">' + '<input type="radio" ng-model="selected" ng-value="false">' +