Encountering an issue with the AngularJS chosen directive, I am receiving the following error:
Error: TypeError: a.map is not a function at nh.q.writeValue (angularjslatest.js:307) at Object.e.$render (angularjslatest.js:328) at angularjslatest.js:310 at angularjslatest.js:146 at m.$digest (angularjslatest.js:147) at m.$apply (angularjslatest.js:150) at l (angularjslatest.js:102) at XMLHttpRequest.s.onload (angularjslatest.js:108)
Explanation of my code:
<select chosen
multiple
class="form-control oditek-form"
name="category"
id="category"
ng-model="category"
ng-options="s.value as s.name for s in listOfCategory">
</select>
The controller code is provided below.
$scope.listOfCategory = [{
name: 'Select Category',
value: ''
}];
$scope.category = $scope.listOfCategory[0];
var fileURL = '';
var url1 = '../service/admin/vechile/service/service.php?action=getAllCategoryData';
var method = 'GET';
var data1 = '';
DataService.connectToServerSideScript(method, url1, data1).then(function(response) {
if (response.length > 0) {
angular.forEach(response, function(obj) {
var cdata = {
'name': obj.category_name,
'value': obj.id
};
$scope.listOfCategory.push(cdata);
})
}
}, function(error) {
});
Although I am successfully retrieving all the data, there are still errors appearing in the browser console. My objective is to resolve these errors.