Showing posts with label $scope. Show all posts
Showing posts with label $scope. Show all posts

Monday, July 6, 2015

$scope service in AngularJS

$scope is the most commonly used built-in service in AngularJS, $scope acts as the model object, it glues the controller with the view, $scope holds the objects/properties. $scope enables 2-way binding between the view and the model, properties of $scope can be set in the controller and bound to the object, any changes made in the view will get automatically reflected in the $scope.

The below example demonstrated the use of $scope object to bind between the model and the view.

Wednesday, June 24, 2015

Role of $scope in Data Binding

The $scope object is the default model object provided by AngularJS, the $scope acts as the model between the controller and the view layers.

The $scope is a JavaScript object which binds the controller and the view in an AngularJS MVC application. Both the controller and the view can access the $scope object, 2 way binding between the model and view is enabled using the $scope object.

In complex applications where we have the view and controller in different files we explicitly use the $scope object in the view to refer to the properties and methods defined in the model object.

The below example demonstrated the use of $scope object to bind between the model and the view.

Tuesday, February 24, 2015

$scope object

In the previous posts we saw on how to use the ng-bind directives to bind objects/properties to the view, in this post we shall see on how to use the $scope object to bind data the controller and the view.
The $scope is a JavaScript object which binds the controller and the view in an AngularJS MVC application. Both the controller and the view can access the $scope object, 2 way binding between the model and view is enabled using the $scope object.

In complex applications where we have the view and controller in different files we explicitly use the $scope object in the view to refer to the properties and methods defined in the model object.

The below example demonstrated the use of $scope object to bind between the model and the view.