我想要实现的是使用依赖于"父"组合框的项目填充子组合框.
为了澄清 - 或者更好的问题,我在这个链接下创建了一个小提琴.
每当组合框'组'发生变化时,组合框'项目'应该填充.
控制器:
function Controller( $scope ) {
var groups = [ ]; // ommitted for the sake of clarity
$scope.groups = groups; // <- linked to cboGroup
$scope.currentGroup = groups[0]; // <- should be updated from combobox
$scope.currentItems = $scope.currentGroup.Items; // <- linked to cboItems
$scope.currentItem = $scope.currentItems[0]; // <- should be updated from cboItems
}
Run Code Online (Sandbox Code Playgroud)
视图
<select data-ng-model="currentGroup" data-ng-options="group.Name for group in groups"></select>
<select data-ng-model="currentItem" data-ng-options="item.Name for item in currentItems"></select>
Run Code Online (Sandbox Code Playgroud)
我无法以声明的方式将这一点变为现实.这应该没有魔术javascript工作 - 不应该吗? …