mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-03 04:34:44 +00:00
radio now works with repeaters
This commit is contained in:
parent
5bd23fde7a
commit
35ca4fcb9c
4 changed files with 8 additions and 4 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
<script type="text/javascript" src="../src/angular-bootstrap.js#autobind"></script>
|
<script type="text/javascript" src="../src/angular-bootstrap.js#autobind"></script>
|
||||||
</head>
|
</head>
|
||||||
<body ng-init="$window.$scope = $root">
|
<body ng-init="$window.$scope = $root">
|
||||||
<table>
|
<table ng-repeat="i in [0, 1]">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Test</th>
|
<th>Test</th>
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ function errorHandlerFor(element, error) {
|
||||||
elementError(element, NG_EXCEPTION, isDefined(error) ? toJson(error) : error);
|
elementError(element, NG_EXCEPTION, isDefined(error) ? toJson(error) : error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var scopeId = 0;
|
||||||
function createScope(parent, Class) {
|
function createScope(parent, Class) {
|
||||||
function Parent(){}
|
function Parent(){}
|
||||||
function API(){}
|
function API(){}
|
||||||
|
|
@ -103,6 +104,7 @@ function createScope(parent, Class) {
|
||||||
|
|
||||||
extend(api, {
|
extend(api, {
|
||||||
'this': instance,
|
'this': instance,
|
||||||
|
$id: (scopeId++),
|
||||||
$parent: parent,
|
$parent: parent,
|
||||||
$bind: bind(instance, bind, instance),
|
$bind: bind(instance, bind, instance),
|
||||||
$get: bind(instance, getter, instance),
|
$get: bind(instance, getter, instance),
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,9 @@ function initWidgetValue(initValue) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function radioInit(model, view) {
|
function radioInit(model, view, element) {
|
||||||
var modelValue = model.get(), viewValue = view.get();
|
var modelValue = model.get(), viewValue = view.get(), input = element[0];
|
||||||
|
input.name = this.$id + '@' + input.name;
|
||||||
if (isUndefined(modelValue)) model.set(null);
|
if (isUndefined(modelValue)) model.set(null);
|
||||||
if (viewValue != null) model.set(viewValue);
|
if (viewValue != null) model.set(viewValue);
|
||||||
}
|
}
|
||||||
|
|
@ -123,7 +124,7 @@ function inputWidget(events, modelAccessor, viewAccessor, initFn) {
|
||||||
model = modelAccessor(scope, element),
|
model = modelAccessor(scope, element),
|
||||||
view = viewAccessor(scope, element),
|
view = viewAccessor(scope, element),
|
||||||
action = element.attr('ng-change') || '';
|
action = element.attr('ng-change') || '';
|
||||||
initFn(model, view);
|
initFn.call(scope, model, view, element);
|
||||||
this.$eval(element.attr('ng-init')||'');
|
this.$eval(element.attr('ng-init')||'');
|
||||||
element.bind(events, function(){
|
element.bind(events, function(){
|
||||||
model.set(view.get());
|
model.set(view.get());
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ describe("input widget", function(){
|
||||||
'</div>');
|
'</div>');
|
||||||
var a = element[0].childNodes[0];
|
var a = element[0].childNodes[0];
|
||||||
var b = element[0].childNodes[1];
|
var b = element[0].childNodes[1];
|
||||||
|
expect(b.name.split('@')[1]).toEqual('chose');
|
||||||
expect(scope.chose).toEqual('B');
|
expect(scope.chose).toEqual('B');
|
||||||
scope.chose = 'A';
|
scope.chose = 'A';
|
||||||
scope.$eval();
|
scope.$eval();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue