I am totally new in AngularJS and I am using PHP as the server script. I have a PHP class with connection() and getUsers() functions:
public function connect()
{
$this->connection = new PDO("mysql:host={$this->db_host};dbname={$this->db_name}", $this->db_user, $this->db_pass);
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $this->connection;
}
public function getUsers()
{
this->connect = this->connect();
$sql = "SELECT * FROM login";
$stmt = this->connect->prepare($sql);
$stmt->execute();
$res = $stmt->fetchAll();
return json_encode($res);
}
I am stuck at the angular part. How to call a function inside a url using $http.get()
?
$http.get('/angular/conn.php')
.success(function(result)
{
$scope.user = result;
})
.error(function(data, status)
{
$log.log(status);
});
And another question on the side: when using angular with php their is no need to call the class and the function that we should use at the top of each html page ?