簡體   English   中英

如何在Angular js中使用Web API 2($ http post)方法

[英]How to consume Web API 2 ( $http post) method in Angular js

我們無法在angular js中使用Web api2方法

module.exports = function ($http, utils) {
var self = this;
self.login = function (credentials) {
    var config = {
        headers: {
            //'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
            'Content-Type': 'application/json'
        }
    };

    return $http.post(utils.apiUrl('admin/login'), credentials, config); 

     };

};

您實際上是在觸摸服務器,但沒有讀取響應。 由於$ http返回一個promise,正確的方法是:

$http.post(utils.apiUrl('admin/login', credentials, config).then(function(response) {
    return response;
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM