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:

Error Message Hardhat debugging error unsupported engine hardhat, current node v18

Error message npm WARN EBADENGINE  Unsupported engine { package: 'hardhat@2.9.3', required: { node: '^12.0.0 || 14.0.0 || 16.0.0...