ramaralo
ramaralo

Reputation: 1031

Angularjs - Passing the $scope to a controller

In Angular's online free course, I see this:

app.controller('GalleryController', function(){
  this.current = 0;
  this.setCurrent = function(imageNumber){
    this.current = imageNumber || 0;
  };
});

but usually the $scope is passed as an argument to the controller... so, is it really needed?

Upvotes: 0

Views: 42

Answers (2)

ankur
ankur

Reputation: 157

Depends on whether you want to use it inside your controller or not. Since in your controller you are not using $scope, you don't need to pass it as an argument to the controller.

Upvotes: 0

AlexHv
AlexHv

Reputation: 1734

This is the new "controller as" syntax. Check here : https://docs.angularjs.org/api/ng/directive/ngController

Upvotes: 2

Related Questions