Witam,
mój problem wygląda tak, że chce w Angularze wyświetlić sobie dane z bazy danych. Ale oprócz danych wyświetla mi w odpowiedzi także zmienne SESYJNE a nie chciałbym tego i tak myślę, że przez to kod mi nie działa.
{"records":[{"id":"1","item_name":"TEst","price":"1000","description":"Bardzo \u0142adny, nie zniszczony, polecam","thumbnail":null}]}array(1) {
["token"]=>
string(86) "obv0uiba26hrmm3fdq66gu3ul2$2y$10$UXw0Ryyuu.Tr7fB3PbeTZuEoro/2IZhfg0yMcd0GL5Vr8i94.DBp2"
}
KOD angular
var app = angular.module('myApp',[]);
app.config(['$qProvider', function ($qProvider) {
$qProvider.errorOnUnhandledRejections(false);
}]);
app.controller('customersCtrl', function($scope, $http) {
$http.get(URL+'index/test')
.then(function(response) {
$scope.content = response.data.records;
$scope.statuscode = response.status;
$scope.statustext = response.statustext;
});
});
KOD PHP
public function test()
{
$this->addJsonHeader();
$this->model = new DisplayItem();
$all['records'] = $this->model->all();
$this->encodeJson($all);
}
public function encodeJson($data)
{
echo json_encode($data);
}
public function addJsonHeader()
{
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
}
I jak to naprawić?