trying to load userlist from db in laravel using angular
in controller using the below code
public function index(Request $request){
$users = DB::table('user')
->select('Name','Code','Type')
->get();
return view('user.index', ['viewuser' => $users]);
}
in script
$scope.viewUsers=function(){
$('.loader').removeClass('hidden')
var FormData={"condition":''};
$http({
method : "POST",
url : "/user/view",
data: FormData,
}).then(function(response) {
$('.loader').addClass('hidden');
$scope.AllUsers=response.viewuser;
}, function(response) {
console.log(response);
setTimeout(function(){$scope.viewUsers();},3000)
});
}
$scope.viewUsers();
but while loading the page it doent show anything in console i can see that
Error: [$http:baddata] on script's
console.log(response);
line. How to get response to $scope.AllUsers
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire