I have two rectangles. The second selection block is populated from the first selection window.
I applied a filter to the second selection box to fill in according to the options selected in the first selection box. The second selection block is populated from the arrayvar outputformats = [];
This is my code.
HTML
<select name="reporttype"id="reporttype"
ng-init="reporttype='1115'"
ng-model="reporttype">
<option value="1115">Previous Day Composite Report</option>
<option value="1114">ACH Receive</option>
</select>
<select name="outputformat" id="outputformat"
ng-model="outputformat"
ng-options="format for format in outputformats | outputformatfilter: reporttype:this">
</select> Value : {{outputformat}}
Filter
angular.module('myApp.outputformatfilter',[])
.filter('outputformatfilter', function () {
return function (input,selectedreport,scope) {
var outputFormatReport = {"1115":"HTML,PDF","1114":"CSV,EXCEL"};
var outputformats = outputFormatReport[selectedreport].split(',');
return outputformats;
};
});
Now, what I want, when the parameters per second of the selected box changes, its first option should be selected by default , that is, the first option from the array should be selected by default.
UPDATE :
Updated script, added ng-if= reporttype !== ''to the second selection block
Fiddle