fix(radio): fix binding to value={{exp}}

This commit is contained in:
Misko Hevery 2011-11-15 11:03:03 -08:00
parent 8adae2fdf2
commit 5857c44e0c
2 changed files with 17 additions and 0 deletions

View file

@ -878,6 +878,7 @@ function watchElementProperty(modelScope, widget, name, element) {
modelScope.$watch(match[1], function(scope, value){
widget['$' + name] = isBoolean ? !!value : value;
widget.$emit('$validate');
widget.$render && widget.$render();
});
}
}

View file

@ -423,6 +423,22 @@ describe('widget: input', function() {
expect(inputs[0].checked).toBe(false);
expect(inputs[1].checked).toBe(true);
});
it('should data-bind the value attribute on initialization', inject(
function($rootScope, $compile){
$rootScope.choice = 'b';
$rootScope.items = ['a', 'b'];
var element = $compile(
'<li>'+
'<input ng:repeat="item in items" ' +
' type="radio" ng:model="choice" value="{{item}}" name="choice">'+
'</li>')($rootScope);
$rootScope.$digest();
var inputs = element.find('input');
expect(inputs[0].checked).toBe(false);
expect(inputs[1].checked).toBe(true);
}));
});