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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -