在这里,我基本上设置了 3 个选择列表
<label for="organization">Organization</label>
<select ng-change="setOrganization()" ng-model="form.organization"
ng-options="o.name as o.displayName for o in organizations" required></select>
<label for="board">Board</label>
<select ng-change="setBoard()" ng-model="form.board"
ng-options="b.id as b.name for b in boards" required></select>
<label for="board">List</label>
<select ng-change="setList()" ng-model="form.list"
ng-options="l.id as l.name for l in lists" required></select>
JS:
$scope.setOrganization = function(){
$scope.lists = {};
mySerivce.get('....', function(boards){
$scope.boards = angular.fromJson(boards);
$scope.$apply();
});
};
$scope.setBoard = function(){
mySerivce.get('...', function(lists){
$scope.lists = angular.fromJson(lists);
$scope.$apply();
});
};
因此,当一个组织被选中时,我会得到板子并用板子数据填充第二个选择字段。Again when a board is selected all lists assigned to the board are fetched and the third select field is set with this data. 在所有选择字段都具有选定值之前,表单将保持无效。
当用户更改组织时,所有字段都会被清除。但是 form.$valid 对象仍然是 true。问题出在哪里?当没有选择任何值时,表单必须是无效的,因为这些字段是必需的。有任何想法吗?