Answer the question
In order to leave comments, you need to log in
Solve the problem with the list of objects?
Started learning AngularJS, ran into a problem.
I'm trying to display a list of students that I receive from the server in json.
for page navigation in the table I use smart-table
Controller:
studentsControllers.controller('StudentsListCtrl', ['$scope', 'Student',
function($scope, Student) {
$scope.itemsByPage=3;
$scope.studentsCollection = Student.query();
console.log($scope.studentsCollection);
}]);
studentsServices.factory('Student', ['$resource',
function($resource){
return $resource(':studentId.json', {}, {
query: {method:'GET', params:{studentId:'all'}, isArray:true}
});
}]);
[
{
"id":1,
"fio":"Иванов Иван Иванович",
"birthday":"10.08.1983",
"phone":"34563463",
"email":"[email protected]",
"image":"",
"is_active":1
},
{
"id":2,
"fio":"Смирнов Михаил Петрович",
"birthday":"25.08.1983",
"phone":"73263463465",
"email":"[email protected]",
"image":"",
"is_active":1
}
]
Answer the question
In order to leave comments, you need to log in
try like this
// вместо
$scope.studentsCollection = Student.query();
// сделать
Student.query().success(function(response){
$scope.studentsCollection = respose;
})
I strongly recommend using Restangular for CRUD operations .
Very cool library.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question