I tried to call function defined in a service.
var app = angular.module('title', ['flash', 'ngAnimate', 'ngRoute'],
function ($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
})
.service('getWidgets', function (globalServices, $http) {
var getData = function() {
var getWidgetUrl = globalServices.baseUrl + "admin/widget/list-text-widget";
return $http({method:"GET", url:getWidgetUrl})
.then(function(result){
return result.data;
});
};
return { getData: getData };
});
Calling section
var widget = getWidgets.getData()
.then(function (result) {
$scope.widgets = result;
$scope.$apply();
});
But it return an error getWidgets.getData is not a function.
What would be the root cause?
angular.module('dss').controller('widgetCtrl', ['$scope', '$compile', '$window', '$location', '$http', 'globalServices', 'Flash', '$timeout', '$sce', '$routeParams', 'getWidgets', widgetCtrl]); function widgetCtrl($scope, $compile, $window, $location, $http, globalServices, getWidgets, Flash, $timeout, $sce, $routeParams) { var widget = getWidgets.getData(); widget.then(function (result) { $scope.widgets = result; $scope.$apply(); }); }'globalServices', 'Flash', '$timeoutbut the controller function have:globalServices, getWidgets, Flash,