Me gustaría llamar a un archivo php desde Angular pasando el parametro usuario y clave .
import { Component, OnInit } from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';
@Component({
selector: 'app-api-login',
templateUrl: './api-login.component.html',
styleUrls: ['../app.component.css']
})
export class ApiLoginComponent implements OnInit {
usuario:String;
clave:String;
register:Boolean;
constructor() {
this.usuario="PrecaNuevo"
this.clave="PrecaNuevo";
this.register=false;
}
ngOnInit() {
var conAjax = $http.post("pgular/php/login.php", {usuario: this.usuario, clave: this.clave});
conAjax.success(function(respuesta){
console.log(respuesta);
});
}
}
Recibo el error: ERROR ReferenceError: $http is not defined
He empezado hoy con Angular, seguro que faltan algunas cosas.