I present my problem:
I have a dynamic form, this has several fields and among them I have a selection that has the options: chapter, subchapter, level 1, level 2, level 3 and level 4, every time I select an option of this select a new one is created form below the previous one that is exactly the same and so on.
What I occupy is that when I select an option of my select and another form is created, in this next form only certain options based on the previously selected one come, for example: that when selecting Chapter in the next one select only you of options Subchapter and Level 1, then if you select Level 2 you only of option to select Level 3.
I enclose the code that I have, ALL THIS ONLY WITH ANGULARJS
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', ['$scope', function($scope) {
$scope.choices = [{id: 'choice1'}];
$scope.addNewChoice = function() {
var newItemNo = $scope.choices.length+1;
$scope.choices.push({id:'choice'+newItemNo});
};
$scope.removeChoice = function(index) {
$scope.choices.splice(index, 1);
};
var initialOptions = ['Capitulo', 'Subcapitulo', 'Nivel 1', 'Nivel 2', 'Nivel 3', 'Nivel 4'];
$scope.options = initialOptions;
$scope.selectedOption = $scope.options[0];
}]);
<div ng-app="angularjs-starter" ng-controller="MainCtrl">
<fieldset class="form-group" data-ng-repeat="choice in choices">
<form name="myForm">
<select ng-model="selectedOption" ng-options="o for o in options" > ng-change="addNewChoice()">
</select>
<input type="number" ng-model="choice.clave" name="" placeholder="Ingresa > la clave">
<input type="text" ng-model="choice.concepto" name="" placeholder="Ingresa el concepto">
<input type="text" ng-model="choice.unidad" name="" placeholder="Ingresa la unidad" min="0">
<input type="number" ng-model="choice.cantidad" name="" placeholder="Ingresa la cantidad" min="0">
<input type="number" ng-model="choice.punitario" name="" placeholder="Precio unitario" min="0" ng-click="showme=true">
<input type="number" ng-model="choice.importe" name="" placeholder="Importe">
<button class="remove btn btn-danger" ng-show="$last" ng-click="removeChoice($index)">Eliminar</button>
</fieldset>
</form>
<button class="addfields btn btn-primary" ng-click="addNewChoice()">Agregar</button>
</div>