0

I have injected $location service to controller. But $location service is not defined inside method. Please help.

app.controller('MainCtrl',['$scope','$location','$mdDialog','MainViewService','$http',
     function($scope, $location,$mdDialog,MainViewService,$http) {
        $scope.pushView = function(){
                    //$location.path
                    //$locaiton undefined <-- Problem
            };
    }]);
1
  • 2
    I highly doubt that this code is the problem. Are you sure that you do not have a typo in your code? Commented Jan 18, 2016 at 21:28

1 Answer 1

1

You are missing the closing bracket!

app.controller('MainCtrl',['$scope','$location','$mdDialog','MainViewService','$http',
    function($scope, $location,$mdDialog,MainViewService,$http) {
    $scope.pushView = function(){
                //$location.path
                //$locaiton undefined <-- Problem
        };
}
] // <-- missing closing bracket
);
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for answering....But I forgot to paste ] in question.. there is no syntactical error. And I dnt know what type of dependancy $location requires.. I am not able to find $location object in my controller funtion
$location is an Angular standard service without dependencies. If there is an error then it's not within the code you posted. For further suppor provide a Plunker with your problem.

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.