JSFiddle - React, Tailwind, and code Playground
HTML
<body ng-app="demoApp">
<div ng-controller="DemoController">
<div>
<select ng-model="firstSelect"
ng-options="opt as opt.label for opt in options">
</select>
<br><br>
<div ng-if="firstSelect.value == '4'" ng-model="secondSelect">
<select
ng-options="opt as opt.name for opt in captions">
</select><br>
<select ng-model="secondSelect"
ng-options="opt1 as opt1.name for opt1 in captions1">
</select><br>
</div>
<select ng-if="firstSelect.value == '3'" ng-model="secondSelect"
ng-options="opt as opt.name for opt in captions1">
</select><br>
</div>
</div>
</body>
JavaScript
angular.module('demoApp', []).controller('DemoController', function($scope) {
//my first drop down loads with the page
$scope.options = [
{ label: 'three', value: 3 },
{ label: 'four', value: 4 }
];
$scope.firstSelect = $scope.options[3];
//the second drop down loads after the first makes a selection. In the real code I am populating the second from localstorage, but once it's assigned its default value I cannot change it.
var init = function(){
//depends on what was selected in first select
$scope.captions = [
{ name: 'A', value: 'a' },
{ name: 'B', value: 'b' },
{ name: 'C', value: 'c' },
{ name: 'D', value: 'd' },
{ name: 'E', value: 'e' }
];
$scope.captions1 = [
{ name: 'A', value: 'a' },
{ name: 'B', value: 'b' }
];
$scope.secondSelect = $scope.captions[1];
$scope.captions1 = [
{ name: 'Aq', value: 'aq' },
{ name: 'B', value: 'b' },
{ name: 'C', value: 'c' },
{ name: 'D', value: 'd' },
{ name: 'E', value: 'e' }
];
$scope.secondSelect = $scope.captions[1];
}
init();
});