0

Here is a simple example of constructing a controller. What if I need to add the $location in my controller?

e.g.

function ExampleCtrl($scope,$location){
    $scope.data = "some data";
    $location.path('/');
}

How should the array notation look like?

Community
  • 1
  • 1
Diolor
  • 12,691
  • 27
  • 105
  • 173

1 Answers1

1

Try this syntax:

app.controller("ExampleCtrl", ['$scope','$location', function($scope , $location){
     $scope.data = "some data"; 
}]);
Ivan Chernykh
  • 40,230
  • 12
  • 130
  • 145