0

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?

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

I'm affraid that is not the case. The current prop and the setCurrent method work as if they were defined on $scope. So it is not a metter of needing it or not. Thanks anyway.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.