in my script, i have this line..
$scope.items = [{"id":"1","name":"name 1","description":"description 1","field3":"field3 1","field4":"field4 1","field5 ":"field5 1"}];
i made a data.php file to simulate the array value of $scope.items shown above
<?php
getaccessories = array("id"=>"1","name"=>"name 1","description"=>"description 1","field3"=>"field3 1","field4"=>"field4 1","field5 "=>"field5 1");
echo json_encode($getaccessories);
?>
the idea is to receive this array from data.php to $scope.items in my script via jquery.get(). i tried below statement with no result. how will it be done?
$scope.items = $.get("data.php", function(data){}, "json");
@sergiu, here's what you have asked me to do for data.php, please see if i did it right?
<?php
// $getaccessories = array("id"=>"1","name"=>"name 1","description"=>"description 1","field3"=>"field3 1","field4"=>"field4 1","field5 "=>"field5 1");
$getaccessories = array();
$accessory = new stdClass();
$accessory->id = "1";
$accessory->name = "name 1";
$accessory->description = "description 1";
$accessory->field3 = "field3 1";
$accessory->field4 = "field4 1";
$accessory->field5 = "field5 1";
$getaccessories[] = $accessory;
echo json_encode($getaccessories);
?>
------ EDIT for Sergiu ------
this is the output of chrome's console.log with the original value of $scope.items
[Object]
0: Object
age: 50
name: "Moroni"
__proto__: Object
length: 1
__proto__: Array[0]
and here's $scope.items with $.get()
Object {readyState: 1, setRequestHeader: function, getAllResponseHeaders: function, getResponseHeader: function, overrideMimeType: function…}
$$v: Array[1]
0: Object
age: 50
name: "Moroni"
__proto__: Object
length: 1
__proto__: Array[0]
i'm hope this helps