I have a scenario where i need to create drop-down dynamically inside ng-repeat and the data source for drop-down is also dynamic, meaning based on the query i need to bind my dropdown.
So, i decdided to call controller method, where i have a http get, by passing the query based on the query my service will return a generic data with key value pair. when i call the controller method i am ending up wih infinte loop
Error: $rootScope:infdig Infinite $digest Loop
My Html
<table style="width: 100%">
<tr>
<td colspan="2"><strong>Enter Parameters</strong></td>
</tr>
<tr ng-repeat="x in reportDataParameter.UserParameterList">
<td>{{x.UserParamDefinition.DisplayLabel}}</td>
<td>
<select ng-model="x.Model" ng-options="item.ValueField as item.TextField for item in executeQuery(x.UserParamDefinition.Query)" class="form-control">
<option value="">Please Select</option>
</select>
</td>
</tr>
</table>
Controller
$scope.reportDataParameter = {};
$scope.reportDataParameter = {
"UserParameterList": [
{
"Key": "StateID",
"Value": "?ddl,State,State",
"UserParamDefinition": {
"DataType": "ddl",
"DisplayLabel": "State",
"Model": null,
"Query": "SELECT Id AS ValueField, BankName AS TextField FROM BankDetail"
}
},
{
"Key": "FacilityParentID",
"Value": "?ddl,FacilityParent,FacilityParent",
"UserParamDefinition": {
"DataType": "ddl",
"DisplayLabel": "FacilityParent",
"Model": null,
"Query": "SELECT Id AS ValueField, Name AS TextField FROM Organization"
}
}
],
"ReportTitle": "Facility List By Parent",
"Description": null,
"ReportPage": null
};
$scope.executeQuery = function (query) {
var baseUrl = 'https://localhost:62';
return $http.get(baseUrl + '/api/reports/executequery/' + query).then(function (result) {
return result.data;
});
}