How can we get data from loop of array like we get from ng-repeat use in our views?
I want this:
function test() {
var data = [];
for(var i = 0; i < 10; i++) {
var newtest = {
text: 'text',
class: 'class_name',
user_chat_img: "images/noimage.jpg",
time_stamp: 'myJSON2'
}
// console.log('chat history',myJSON);
data.push(newtest);
}
return data;
}
var $scope.message = test();
console.log('message', $scope.message);
Now i want to get this array values i.e text,class etc
this give me data in console like this
Array[1]
0: Object
class: "class_name"
text: "text",
time_stamp: "myJSON2",
user_chat_img: "images/noimage.jpg"
__proto__: Objectlength: 1__proto__: Array[0]
How can i get these values in my controller i will get these values in my views using ng-repeat like
ng-repeat={x in message}
and then
x.class
thanks