I'm doing a crud of employees, in the employee creation form I have 2 select. The first selection is that of departments, therefore it displays, for example (Dpt. Audit, Informatics, Warehouse, etc). And the second select is that of posts, therefore it returns all the posts that exist.
//Select departamentos
$scope.ObjDepartamentos = {};
$scope.departamentos = [];
$http.get(server+'ws/departamentos').success(function(datas)
{
angular.forEach(datas.records, function(value, key)
{
$scope.departamentos.push({
id: value.id,
title: value.nombre,
value: value.id,
parent_id: value.id
});
});
});
$scope.ObjDepartamentos['departamentos'] = $scope.departamentos;
$scope.confDepartamentos = {
create: false,
maxItems: 1,
placeholder: 'Departamentos...',
optgroupField: 'parent_id',
optgroupLabelField: 'title',
optgroupValueField: 'ogid',
valueField: 'value',
labelField: 'title',
searchField: 'title'
};
//----------------------
HTML:
<input type="text" config="confDepartamentos" options="ObjDepartamentos.departamentos" ng-model="item.iddepartamento" name="iddepartamento" selectize />
Second select:
//Select puestos
$scope.ObjPuestos = {};
$scope.puestos = [];
$http.get(server+'ws/puestos').success(function(datas)
{
angular.forEach(datas.records, function(value, key)
{
$scope.puestos.push({
id: value.id,
title: value.nombre,
value: value.id,
parent_id: value.id
});
});
});
$scope.ObjPuestos['puestos'] = $scope.puestos;
$scope.confPuestos = {
create: false,
maxItems: 1,
placeholder: 'Puestos...',
optgroupField: 'parent_id',
optgroupLabelField: 'title',
optgroupValueField: 'ogid',
valueField: 'value',
labelField: 'title',
searchField: 'title'
};
//----------------------
HTML:
<input type="text" config="confPuestos" options="ObjPuestos.puestos" ng-model="item.idpuesto" name="idpuesto" selectize />
I want to know how: when selecting for example the computer department in the second select only show me the positions that are related to the computer department, it is worth mentioning that in another table I create the posts related to a department .