mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-21 00:40:24 +00:00
fix(radio): fix binding to value={{exp}}
This commit is contained in:
parent
8adae2fdf2
commit
5857c44e0c
2 changed files with 17 additions and 0 deletions
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue