Reputation:
please help me what mistake im doing Here
factory.js
angular.module('MyApp').factory('MilkFactory', function ($http) {
var GeneralService = {};
GeneralService.DoCal = function () {
return $http({
url: 'http://localhost:10948/Api/Home/GetEmployee',
method: 'Get',
contentType: 'application/x-www-form-urlencoded'
EmpCtrl.js
angular.module('MyApp')
.controller('EmployeeController', function ($scope, EmployeeService, $q, MilkFactory) {
$scope.GetFactory = function () {
MilkFactory.DoCal().then(function () {
alert('Milk is calling...')
return
})
}
Upvotes: 0
Views: 360
Reputation: 16801
You need to return the service object from the factory
angular.module('MyApp').factory('MilkFactory', function ($http) {
var generalService = {};
generalService.DoCal = function () {
return $http({...});
};
return generalService;
});
Upvotes: 1