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
  • 13,181
  • 30
  • 111
  • 179

1 Answers1

1

Try this syntax:

app.controller("ExampleCtrl", ['$scope','$location', function($scope , $location){
     $scope.data = "some data"; 
}]);
Ivan Chernykh
  • 41,617
  • 13
  • 134
  • 146