For my Angularjs application, I needed to dynamically return a select drop down with its selected option. To accomplish this, I implemented the following function:
function getCellRendererMapping(data) {
if (data.order == 6) {
return function(params) {
params.$scope.payRateRegDataOptions = data.data;
var dynamicScopename = "data.' + params.colDef.field + data.order +'"
$scope.dynamicScopename = data.data[0];
// console.log("dynamic scope value" + $scope[dynamicScopename]);
return '<select ng-options="eachPayRate.text for eachPayRate in payRateRegDataOptions" name="payrate_s' + params.column.index + '" id="payrate_s' + params.column.index + '" ng-model="dynamicScopename"></select>';
}
}
}
Although the dropdown is forming correctly and being populated with options, I am facing an issue with setting the default selection. Even though I have tried to set the default option using the code below, the ng-model, (dynamicScopename
), is not being properly configured.
$scope.dynamicScopename = data.data[0];