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:

React UI, UI UX, Reactstrap React Bootstrap

React UI MATERIAL  Install yarn add @material-ui/icons Reactstrap FORMS. Controlled Forms. Uncontrolled Forms.  Columns, grid