AngularJS $scope & this

One of the first things you learn with AngularJS is the amazing two-way data binding abilities of $scope. $scope, directives, and curly brackets can magically add content to your website.

But what is $scope? $scope is context or the glue between controllers and html. If you have been programming with Javascript for a while the word context might sound familiar with the keyword this. If you do a google search, the below definition will appear.

Imgur

Have you ever considered using this instead of $scope? Below is an example. Some AngularJS style guides consider the use of $scope bad practice, and use the keyword this instead.

Imgur

Imgur

Written on February 1, 2016