c# - Convert AngularJS service to Angular -
how convert angularjs angular? created component named forgotpassword
, have no idea how correctly send http.post
c# controller.
function (window, angular) { "use strict"; angular.module("mobile") .service("accountservice", ["$http", function ($http) { return { forgotpassword: function (email, success, error) { $http.post("account/forgotpassword", { email: email}).success(success).error(error); } } }]); })(window, window.angular);
you need create service class
app.serivce.ts
import { injectable } '@angular/core'; import { http, response } '@angular/http'; import { observable } 'rxjs/observable'; import 'rxjs/rx'; @injectable() export class appprovider { constructor(private http: http) { } public forgotpassword(email: string):observable<any> { let url:string = 'apiurl/account/forgotpassword'; let body: = { email: email } return this.http.post(url, body).map((res:response) => res.json()); } }
this method called inside component.ts file
Comments
Post a Comment