我是 php 和 angularjs 的新手,
我有 php 代码,它可以像这样返回 json 数据
{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代码
<?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);
?>
我想获取角度范围的数据
Angularjs代码
angular.module('remoteApp')
.factory('Rdpservice2', function ($resource) {
return $resource('scripts/services/rdp2.php', {}, {
query: {method: 'GET'}
});
});
$scope.rdpDate = {'test': Rdpservice2.query()};
错误信息
TypeError: Object #<Resource> has no method 'push'
但 $scope.rdpData 无法获取任何数据?
我很困惑,请帮助