I get the following data from a database in my ionic application. I am saving it to $scope.dbCustomersArray:
[
{
"customer_id":1,
"customer_name":"Test Company",
"customer_address":"17 Morena Blvd Camarillo",
"customer_city":"Ventura",
"customer_contactnumber":"805-832-6163",
"Company_id":1
},
{
"customer_id":2,
"customer_name":"Another test company",
"customer_address":"2742 Distribution Way Metairie",
"customer_city":"Jefferson",
"customer_contactnumber":"504-979-9175",
"Company_id":1
},
{
"customer_id":3,
"customer_name":"Final test company",
"customer_address":"775 W 17th St San Antonio",
"customer_city":"Bexar",
"customer_contactnumber":"210-812-9597",
"Company_id":1
}
]
I am trying to loop through it in my html.
<label class="item item-input" style="padding: 0px">
<div class="row">
<label class="item item-input item-select col">
<div class="input-label" style="visibility: hidden">
Customer
</div>
<select>
<option> -- Customer -- </option>
<ion-item ng-repeat="customer in $scope.dbCustomersArray">
<option> Hello, {{customer.customer_name}}! </option>
</ion-item>
</select>
</label>
</div>
</label>
I am returning no values and not getting any errors in my logs. I have tried to loop through $scope.dbCustomersArray using the following code, but the only values that are printed out are: 0
, 1
and 2
repspectively.
for (var customer in $scope.dbCustomersArray) {
console.log("LOGGING A CUSTOMER - " + customer.customer_name);
}
Please help me with this problem. I don't see where I am going wrong. Thank you in advance.
EDIT
I cant see the values in my array in my ionic application when I tap on the customers select list.
It looks like you have two problems:
When you loop through your object array, 0, 1, 2 sounds accurate because those are your array indices. I think confirming that your controller is loaded and removing $scope will correct your problems.
Regards,