I found another post on this forum which said the normal method of populating selects won't work because when this form is fist shown the process hasn't begun yet.
So I was trying to get a script in the html form to get the select options by calling a rest servlet which returns json.
This seems to be working as I can display the returned data in a javascript alert. But I am not struggling to figure out how to pass this on to the "cam-choices" attribute of my select.
Is anyone able assist or recommend a suitable example.
Code is as follows:
<form cam-form role="form">
<script cam-script type="text/form-script">
inject([ '$scope', '$http', function($scope, $http) {
camForm.on('form-loaded', function() {
$http({
method: 'GET',
url: 'http://w7-develop2:8080/ServletTest/JsonServlet?q=XXX%20YYY%20ZZZ'
}).then(
function successCallback(response)
{
alert('SUCCESS :-) ' + angular.toJson(response.data));
$scope.data = response.data
},
function errorCallback(response) {
alert('FAILED :-( ' + response.status);
});
});
}]);
</script>
<div class="form-group">
<select cam-variable-name="companyId"
cam-variable-type="String"
cam-choices="{{data}}">>
</select>
</div>
Thanks in advance for any assistance