2014-03-26 41 views
7

沒有方法Get的參數,代碼有效,但是如果方法詢問參數,則返回錯誤404。我如何正確地發送參數與Angular JS?Angular JS AJAX調用參數

factory.test = function() { 
    var q = $q.defer(); 

    $http({ 
     method: "GET", 
     url: url + "/dataEntry/test", 
     data: { 
      sampletext : "sample" 
     } 
    }) 
     .success(function (data, status, headers, config) { 
      q.resolve(data); 
     }) 
     .error(function (data, status, headers, config) { 
      q.reject(data); 
     }); 

    return q.promise; 
}; 

[Route("test")] 
    public String Get(string sampletext) 
    { 
     return "Reply coming from data entry controller" + sampletext; 
    } 
+0

什麼是你的後盾? ASP.Net MVC? –

+0

是的。 ASP .Net MVC – ElementaryStudentProgramming

回答

-2
$http({ 
    url: "/saveInfo", 
    method: 'Post' 
}).then(function(response) { 
    console.log("saved successfully"); 
}, function(response) { 
    console.log("Error message"); 
});