how can I do that please ?
Angular/Laravel pagination api
Hello ,I am new with angularJS/laravel , so I succed to get all my api resource with laravel and angularJS. but I still want to make a pagination to the api.
If your are sending a paginated response, you have everything (all details) in there, whats bothering you ?
@d3xt3r No :o myController resource
public function index(Request $request)
{
$questions = Question::all();
return $questions;
}
public function show($id)
{
$questions = Question::all();
return $questions;
}
You clearly have no idea what you are doing. Start with the basics!!
@bobbybouwmann how do you know ? I work with Laravel for 3 years, u have reduced the respect
@Amelie89 Don't be judgemental, its Saturday after all. you need to use paginate() in order to get the paginated response, then you can create components in angular to handle it.
Example:
public function index(Request $request)
{
$questions = Question::paginate(15); // or whatever you like
return $questions;
}
@d3xt3r thankyou for your answer , I already tried that but it didn't work , ( I can see the data on the console but no data displayed on the browser)
You will have to modify your angular scripts, with pagination the actual data is contained within data object ...
Did you Google for it?
https://www.codetutorial.io/laravel-5-pagination-angular-js-load/
@bobbybouwmann @d3xt3r dosen't work for me
var app = angular.module('app', [], function($interpolateProvider) {
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
});
app.controller('questionController', function($scope, $http) {
$scope.questions = [];
$scope.historiques = [];
$scope.loading = false;
$scope.init = function() {
$scope.loading = true;
$http.get('/api/v1/questions').
success(function(data, status, headers, config) {
$scope.questions = data;
$scope.loading = false;
});
}
$scope.init();
});
what code should be added on the angular file script
Please or to participate in this conversation.