如何获取AngularJS登录表单后需要

时间:2015-08-19 19:12:04

标签: angularjs google-chrome

鉴于AngularJS示例登录表单here,如何在单击“登录”按钮时知道发送的帖子请求是什么?

我尝试使用Chrome的开发人员工具网络标签,但我得到的只是GET请求。

谢谢!

enter image description here

1 个答案:

答案 0 :(得分:1)

如果你看一下plunkr的源代码,你会发现:

service.Login = function (username, password, callback) {

    /* Dummy authentication for testing, uses $timeout to simulate api call
     ----------------------------------------------*/
    $timeout(function(){
        var response = { success: username === 'test' && password === 'test' };
        if(!response.success) {
            response.message = 'Username or password is incorrect';
        }
        callback(response);
    }, 1000);


    /* Use this for real authentication
     ----------------------------------------------*/
    //$http.post('/api/authenticate', { username: username, password: password })
    //    .success(function (response) {
    //        callback(response);
    //    });

};

因此,虚拟身份验证不会发送任何HTTP请求,因为它是一个“模拟”HTTP调用的虚拟超时函数。

您看到GET请求有一个AJAX调用来加载部分home.html视图。