I'm walking through the basics of Angular and know very little about controllers, directives, scope, models etc. In the video, the tutor wrote controllers in this way:
var module = angular.module('name', [dependencies])
.controller($scope)...
The only thing I want you to pick from the above snippet is that, he (the tutor) is passing the $scope object to the controller's function. That is fine and that worked.
In an example on official Angular website, I found this code:
angular.module('invoice1', [])
.controller('InvoiceController', function() {
this.qty = 1;
this.cost = 2;
this.inCurr = 'EUR';
this.currencies = ['USD', 'EUR', 'CNY'];
this.usdToForeignRates = {
USD: 1,
EUR: 0.74,
CNY: 6.09
};
I can clearly see that in this example, no $scope
is being passed and this
is used instead. Does this mean that the $scope
passed to a controller function and 'this' inside a controller function are identical objects?