Attempting to utilize ng repeat for extracting values from an array.
Below is the HTML code:
<ion-list ng-repeat="item in locationresult">
<ion-item >
<ion-checkbox ng-repeat="innerItem in item.loc[$index]">
<h2>{{innerItem.name}}</h2>
<p>Income:1334 vs Expenses:3742</p>
</ion-checkbox>
</ion-item>
</ion-list>
Here is the controller:
angular.module('starter').controller('locationCtrl', function($scope, $state, userlog, $http, $timeout) {
$scope.init = function() {
$timeout(function() {
alert(userlog.email);
document.getElementById("locresult").textContent = "";
var request = $http({
method: "post",
url: "http://expensetracker.linkwebz.com/Home/locationsearch",
data: {
email: userlog.email,
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
/* Check whether the HTTP Request is successful or not. */
request.success(function(data) {
console.log(data);
$scope.locationresult = data;
});
});
};
});
Data object:
Object { loc: Array[3] }
object
loc:Array[3]
0:Object
iduhlocation:"1"
location_idlocation:"1"
name:"mark"
user_iduser:"177"
_proto_:Object
1:Object
2:Object
length:3
_proto_:Array[0]
_proto_:Object
Struggling to iterate through the array and display all the data in the HTML. Any suggestions on how to achieve this?