I am trying to call my Mvc Controller Action from Angularjs controller $http.get(). Please provide some solution.
Controller Action :
 [HttpGet]
 public string CallMe(int number,string name)
 {
     return "Welcome " + name +" to Angular Js " + number + " times.";
 }
Angular JS Controller
 app.controller("StoreController", ["$http", function ($http) {        
    $http.get("/Home/CallMe", { number: 4, name: "angular"     }).success(function (data) {
        console.log(data);
    }).error(function (error) {           
        console.log(error);
    });
}]);
Also, Could anyone please specify related material for learning?
Thanks in advance.
You are using $http#get method.
get(url, [config]);
 Param    Type     Details
 url      string   Relative or absolute URL specifying the destination of the request
 config   Object   Optional configuration object
(optional)
For passing parameters angular.http provides an option for it params
$http({
   url: "/Home/CallMe", 
   method: "GET",
   params: {number: 4, name: "angular"}
});
                        You're trying to use the get method with post parameters. get only takes a URL parameter, and an optional config one. 
Take a look here at the documentation.
Try to append your parameters to the URL:
 app.controller("StoreController", ["$http", function ($http) {        
    $http.get("/Home/CallMe?number=4&name=angular").success(function (data) {
        console.log(data);
    }).error(function (error) {           
        console.log(error);
    });
}]);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With