0

Angularjs Part is not working after Deploying in IIS 8.5 , this is my js file this code works in local machine with Visual Studio 2012

angular.module('MyApp').controller("DataViewController", ["$scope", "RequestService", function($scope, RequestService) {
    $scope.Requests = [];

    RequestService.GetRequests().then(function (d) {
        $scope.Requests = d.data
    });
}])

.factory('RequestService', function ($http) { 
    var fac = {};
    fac.GetRequests = function () {
        return $http.get('/Data/EmployeeRequests');
    }
    return fac;
});
5
  • what does it shows in console? Commented Feb 28, 2016 at 8:05
  • Failed to load resource: the server localhost/Data/EmployeeRequests responded with a status of 404 (Not Found) Commented Feb 28, 2016 at 11:06
  • angular.js:9734 GET localhost/Data/EmployeeRequests 404 (Not Found) Commented Feb 28, 2016 at 11:11
  • i tried your answer but it gives same Result .... Commented Feb 28, 2016 at 11:23
  • can i get a teamviewer Commented Feb 28, 2016 at 11:24

2 Answers 2

1

The problem is your application cannot find the resource

Just change

From:

.factory('RequestService', function ($http) { 
    var fac = {};
    fac.GetRequests = function () {
        return $http.get('/Data/EmployeeRequests');
    }
    return fac;
});

To:

.factory('RequestService', function ($http) { 
    var fac = {};
    fac.GetRequests = function () {
        return $http.get('Data/EmployeeRequests');
    }
    return fac;
});
Sign up to request clarification or add additional context in comments.

1 Comment

This Works with me just need to set the Path as return $http.get('../Data/EmployeeRequests');
0

You are missing explicit type annotations on your factory declaration.

There may be a problem with minification of .js files. On your local machine VS prevents bundle optimization, when you deploy your solution to IIS on prod server - ASP.NET minimizes and bundles all your js and css files. Thus turning

function($http) { ... }

into

function(a) { ... }

To solve problem use explicit annotations:

.controller(['dep1', 'dep2', '$http', function(dep1, dep2, $http) {... }]);

or

Controller.$inject = ['dep1', 'dep2', '$http'];

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.