In AngularJS v1.6.9 I use HTTP post method for calling my API but $$state give me null so I am not able to give my list. I try to debug result = response.data give me to list but when that API Call service but post API function return also the list but in a controller, I enable to fetch that data.Please help me with that
Module is
var adminDashbord = angular
.module('mymodel', ['ui.router', 'ui.bootstrap', 'datatables', 'datatables.buttons']);
My API Call Service is
mymodel.service('ApiCall', ['$http', function ($http) {
var result;
var retResult;
var data;
this.PostApiCall = function (controller, method, jData) {
jData = JSON.stringify(jData);
result = $http.post('http://localhost:2153/' + controller + '/' + method, jData).then(function onSuccess(response)
{
result = response.data;
})
.catch(function onError(response)
{
console.error("CustomError:" + response.data);
console.error("Status:" + response.status);
});
return result;
};
Post API in a controller like
mymodel.controller('productmasterController', ['$scope', 'ApiCall',
function ($scope, ApiCall) {
$scope.init = function ()
{
$scope.getAllproduct();
}
$scope.getAllproduct = function () {
var reqdata = null;
result = ApiCall.PostApiCall("Product", "SelectAllProduct", reqdata).then(function (response) {
$scope.getProduct = response.ProductList;
});
};
}]);
My issue was $$state give an empty result.