Ad

Saturday, January 9, 2016

AngularJS scope $scope object for dummies and beginners

AngularJS scope or $scope is a special angular object. The top level parent scope is called $rootscope, and is created when Angular renders the application page for the first time. All other scopes are children of the rootscope. Though not frequently used, we can use $rootscope to communicate data between scopes.

Every time a new controller and its corresponding data-binding is created a scope is created.

In Angular, we use Services to get data from the server then use $scope to pass the data to the view, the presentation layer.

Tod Motto a famous Angular developer suggests that we think of the $scope as a bridge between the JavaScript and the DOM as a glorified ViewModel.

The essential concept of scope exists in other programming languages and frameworks including vanilla JavaScript. Angualr's $scope comes with its own flavor : it's only used in controllers binds data from the controller to the view

2 comments:

Host an HTML website on Github in 5 minutes HD

Tutorial how to set up web hosting, personal portfolio website on Github in 5 minutes. More content coming to this paid channel including in...