AngularJS $location object doesn't have the path() function [closed]
-
21-12-2019 - |
Question
For some reason my $location object doesn't have the path function when calling in my controller.
Someone an idea?
E: here the Controller
erpmApp.controller('dashboardCtrl', ['$scope', '$http', '$parse','$swipe', '$location', '$rootScope', 'Page', 'Data', 'Config', function ($scope, $rootScope, $http, $parse, $swipe, $location, Page, Data, Config) {
Config.setHeadbarStatus(true);
Page.setTitle('ERP-Mobile');
$scope.dashboarddata = null;
$scope.redirect = function(url) {
console.log($location);
};
$scope.loadDashboard = function() {
if($scope.dashboarddata == null) {
Data.getDashboardMenuData().then(function(response){
$scope.dashboarddata = response;
});
}
};
}]);
Solution
You have your dependency names mixed up
['$scope', '$http', '$parse','$swipe', '$location', '$rootScope', 'Page', 'Data', 'Config', function(
$scope, $rootScope, $http, $parse, $swipe, $location, Page, Data, Config) {
Which means, what you assume is $location
is actually '$rootScope'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow