我是 angularjs 和 php 的新手
我想从数据库中获取数据,
但出现错误“错误:未知提供者:$resourceProvider <- $resource <- Rdpservice”
代码
angular.module('remoteApp')
.factory('Rdpservice', function ($resource) {
return $resource('connect.php', {}, {
query: {method: 'GET'},
get: {method: 'GET'},
remove: {method: 'DELETE'},
edit: {method: 'PUT'},
add: {method: 'POST'}
});
});
<?php
$con=mysqli_connect("localhost","user","password");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="CREATE DATABASE my_db";
if (mysqli_query($con,$sql))
{
echo "Database my_db created successfully";
}
else
{
echo "Error creating database: " . mysqli_error($con);
}
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
mysqli_close($con);
?>