I'm new to angularjs.
What is the difference if You assign function to $scope or this keywords in the controller?
Thank You.
Example (scope):
.controller('TestCtrl', ['$scope', function ($scope) {
$scope.testFunc = function () {
};
}]);
Example (this)
.controller('TestCtrl', [function () {
var app = this;
app.testFunc = function () {
};
}]);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…