Reputation:
I have one big issue.I need to select multiple value from drop down list ,for that i used bootstrap-multiselect.js
getting the below error.
angularjs.js:107 TypeError: a.forEach is not a function
at u.writeValue (angularjs.js:273)
at f.$render (angularjs.js:285)
at Object.<anonymous> (angularjs.js:265)
at n.$digest (angularjs.js:130)
at n.$apply (angularjs.js:133)
at HTMLInputElement.<anonymous> (angularjs.js:253)
at HTMLInputElement.m.event.dispatch (jquery.js:4670)
at HTMLInputElement.r.handle (jquery.js:4338)
here i have the below button.when user will click this the drop down list is loading dynamically.
<input type='button' class='btn btn-xs btn-green' value='Send' ng-click="sendVoucherCode(code.voucher_code_id,code.expired_date,code.customer_name);" ng-hide="sendButton">
when user is clicking the above button the below drop down list has to load dynamically .
<select class="form-control" id="lstFruits" ng-model="voucher_code" ng-options="code.name for code in listOfCode track by code.value " ng-change="removeBorder('lstFruits')" multiple="multiple">
</select>
The controller side code for the above drop down list is given below.
$scope.sendVoucherCode=function(voucherid,expierdate,cname){
$scope.listOfCode=[{
name:'Select Voucher Code',
value:''
}]
$scope.voucher_code=$scope.listOfCode[0];
var code={'voucher_code_id':voucherid};
$http({
method:'POST',
url:"php/getVoucherNotifyCode.php",
data:code,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function successCallback(response){
console.log('voucher code',response.data);
$scope.codeImage=response.data[0].image;
$scope.arrCode=response.data[0].generated_code.split(',');
for(var i=0;i<$scope.arrCode.length;i++){
var data={'name':$scope.arrCode[i],'value':$scope.arrCode[i]};
$scope.listOfCode.push(data);
}
},function errorCallback(response) {
})
}
$('#lstFruits').multiselect({
includeSelectAllOption: true
});
Here when the above function is called the error is coming and drop down field is not opening.Here also i need when user will click on the send button the dynamic value will load inside the drop down list and user can fetch one/mupltiple value,those value will again collected inside the controller side function.Please help me to resolve this issue.
Upvotes: 0
Views: 82
Reputation: 1
Seems like voucher_code is not bind with an array. If multiselect is bind with an object this error arise.
Upvotes: 0