Angular 2 How to send mail PHP?

前端 未结 2 1946
庸人自扰
庸人自扰 2020-12-30 18:21

I learning angular 2, and I don\'t see any example on the web to send a simple contact form from angular 2 to php scrip.

My html template.



        
2条回答
  •  粉色の甜心
    2020-12-30 18:43

    For anyone that's interested in doing this in later versions of Angular, you'll notice that @angular/http is deprecated and cannot be used without an error.

    You should do all the above from HPierce but you use HttpClient instead:

    import {HttpClient} from "@angular/common/http";
    

    Then convert all your types to HttpClient instead, e.g.:

    http : HttpClient;
    
      constructor( http: HttpClient) {
        this.http = http;
      }
    

    And you'll also need to import HttpClientModule into your app.module.ts!

提交回复
热议问题