I need your help. I've resolved my issue partially but not able to figure out things to make it dynamically.
Requirements: I've two Panels which will only appear based upon selection of dropdown list values
Panel Names are : Panel_1 and Panel_2 Dropdown list values: Panel1 and Panel2
My code which is working fine is as follows:
code for dropdown list (hard coded):
<select name="type" ng-model="dataparameters.type" ng-dropdown required ng-change="SelectDDL()">
<option ng-option value="Panel 1">Panel 1</option>
<option ng-option value="Panel 2">Panel 2</option>
</select>
Code For Panels:
<div class="panel panel-default" style="width:650px" id="P1" ng-if="dataparameters.type == 'Panel 1'">
<div class="panel-heading">
Panel_1
</div>
<div class="panel-body">
<div>
<label class="col-xs-6 control-label">Panel1 :</label>
<div class="col-xs-6">
<input type="number" class="form-control" ng-model="dataparameters.P1" />
</div>
</div>
</div>
</div>
<div class="panel panel-default" style="width:650px" id="P2" ng-if="dataparameters.type == 'Panel 2'">
<div class="panel-heading">
Panel_2
</div>
<div class="panel-body">
<div>
<label class="col-xs-6 control-label">Panel2 :</label>
<div class="col-xs-6">
<input type="number" class="form-control" ng-model="dataparameters.P2" />
</div>
</div>
</div>
</div>
Angular.JS file code:
var application = angular.module('AddEditComponentApp', []);
application.controller('addeditcomponentcontroller', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.Selected_DataParameters_Add = {}
$scope.SelectDDL = function () {
}
}]);
Here we can see the dropdown list is hardcoded. I've filled my dropdown list dynamically from the database but after that panel visibility is not working.
Code to fill dropdown list is as follows:
<select id="Selected_DataParameters_Add" ng-model="$scope.Selected_DataParameters_Add" ng-options="dp.Data_Parameter_Name for dp in DataParameters" ng-dropdown required ng-change="Checked()">
<option ng-option value="">Select Data Fields</option>
</select>
I think the only problem is I'm not able to understand how to fill values dynamically to ng-option value=""