1

I am new to Angular JS. I have a MVC Area called "Setup". Under this area there is a Controller called ModuleMstController.

The above controller has an Action method GridData.

From my Angular controller i make a post with a url /Setup/ModuleMst/GridData

but firebug shows the request url as

http://localhost/ModuleMst/GridData

and my action method is not hit.

I then tried to configure routing as

var ap = angular.module('myApp', ['trNgGrid', 'ngRoute']);

//controller 1
ap.controller("MainCtrl", function ($scope, $http) {
    $scope.model = {};

......
....

$scope.isAjaxInProgress = true;
$scope.errorMessage = undefined;

$http.post("/ModuleMst/GridData", $scope.requestedItemsGridOptions)
.then(function (data) {
    $scope.model.itemList = data.items;
    $scope.model.totalCount = data.TotalCount;
}
,function () {
    $scope.errorMessage = "An Error has occured while loading data!";
});

})
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {

    $routeProvider.when('/ModuleMst', {
        templateUrl: '/Setup/ModuleMst/GridData'
        //controller: 'ModuleMst',
    });
    $routeProvider.otherwise({
        redirectTo: '/'
    });

    $locationProvider.html5Mode(false).hashPrefix('!');

}]);

I have not touched the routing configuration in the server side. It works with jquery ajax but not with angular $http.post().

How do i make this work ?

Thanks for the help.

2
  • Can you show the code where you do $http.post? Commented Apr 14, 2016 at 6:57
  • @fikkatra Its in the source :) Line no 13 Commented Apr 14, 2016 at 6:59

1 Answer 1

1

Pass the MVC area in the http post:

$http.post("/Setup/ModuleMst/GridData", $scope.requestedItemsGridOptions)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.