angularjs – 在嵌套的ng-repeat指令中使用ng模型

我正在尝试使用ng-model“内部”ng-repeat指令,它本身嵌套在ng-repeat指令中。

以下jsfiddle演示了我的问题和我的两个尝试来解决它。

http://jsfiddle.net/rskLy/4/

我的控制器定义如下:

var mod = angular.module('TestApp',[]);
mod.controller('TestCtrl',function ($scope) {        
var machine = {};
machine.noteMatrix = [
    [false,false,false],[false,true,false]
];

$scope.machine = machine;

// ...
});

1。

<table>
    <thead>
        <tr>
            <th>--</th>
            <th ng-repeat="no in machine.noteMatrix[0]">{{$index+1}}</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="track in machine.noteMatrix">
            <td>--</td>                
            <td ng-repeat="step in track">                    
                <input type="checkBox" ng-model="track[$index]"> {{step}}
            </td>
        </tr>
    </tbody>
</table>

一个示例/尝试更新控制器内的machine.noteMatrix,但是每当按下复选框时,angularjs会在javascript控制台中显示两次错误

Duplicates in a repeater are not allowed. Repeater: step in track

有时它也会显示这个错误

Duplicates in a repeater are not allowed. Repeater: no in machine.noteMatrix[0]

2。

<table>
    <thead>
        <tr>
            <th>--</th>
            <th ng-repeat="no in machine.noteMatrix[0]">{{$index+1}}</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="track in machine.noteMatrix">
            <td>--</td>                
            <td ng-repeat="step in track">                    
                <input type="checkBox" ng-model="step"> {{step}}
            </td>
        </tr>
    </tbody>
</table>

第二个示例/尝试从notesMatrix读取数据,并且在检查/取消选中复选框时,javascript控制台中不会显示任何错误。但是,更改其状态并不会更新控制器中的machine.noteMatrix(按“显示矩阵”按钮可查看jsfiddle中的矩阵)。

任何人都可以看清这个吗?

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...