I am new with php and angularjs ,
I have php code , it can return json data like this
{id:10, sessionName:99, computer:99, quality:LAN(very fast), networkAuthentication:Disable,…}
{id:13, sessionName:55, computer:55, quality:LAN(very fast), networkAuthentication:Disable,…}
{id:14, sessionName:bb, computer:bb, quality:LAN(very fast), networkAuthentication:Disable,…}
{id:15, sessionName:77, computer:77, quality:LAN(very fast), networkAuthentication:Disable,…}
{id:16, sessionName:00, computer:00, quality:LAN(very fast), networkAuthentication:Disable,…}
PHP CODE
<?php
include 'config_open_db.php';
$sql= "select * from rdp";
$sth = mysql_query($sql);
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
?>
I want get data with angular scope
Angularjs CODE
angular.module('remoteApp')
.factory('Rdpservice2', function ($resource) {
return $resource('scripts/services/rdp2.php', {}, {
query: {method: 'GET'}
});
});
$scope.rdpDate = {'test': Rdpservice2.query()};
ERROR MESSAGE
TypeError: Object #<Resource> has no method 'push'
but $scope.rdpData can't get any data?
I am so confused, please help
[{...},{...},...]
. I.e. brackets around the objects and commas between them. – Nikos Paraskevopoulos Sep 16 at 9:44json_encode( $rows );
; where does it come from? – feeela Sep 16 at 9:50