I am trying to use ng repeat to get values from array
here is my html
<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 Expences:3742</p>
</ion-checkbox>
</ion-item>
</ion-list>
here is my controler
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;
});
});
};
});
here is my 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
I tried to repeat data as mention above html it's not working how i iterate through array and show all data in html have idea any one?
You can use only one ng-repeat
if your data is as you have shown as:
<ion-list ng-repeat="item in locationresult['loc']">
<ion-item >
<ion-checkbox>
<h2>{{item.name}}</h2>
<p>Income:1334 vs Expences:3742</p>
</ion-checkbox>
</ion-item>
</ion-list>