Angular use scope object Example

Angular use scope object Example

Today, We want to share with you Angular use scope object Example.
In this post we will show you Angular use scope object Example, hear for Angular use scope object Example we will give you demo and example for implement.
In this post, we will learn about Angular use scope object Example with an example.

The $scope varible in an AngularJS is a one type of built-in object, which contains (join) web-application data and all methods.

READ :  C# Boxing & Unboxing Tutorial with Examples

AngularJS : Defination of Scope.

The scope is the binding part between the HTML page (view-side) and the JavaScript side (controller part). The scope is an one type of object with the available some properties and methods.Simple Means (Scope is join between html page and controller)

The main purpose of a Scope variable is to “join two phase” the presentation view and the business logic controller of your web-application.

The Scope main contains the model of data. In controllers logic data, model data is accessed via using $scope object. Simple Means : connects to controllers and view.

Main purpose of Scope

  • View, which is the HTML.
  • Model ->data available for the current view
  • Controller – >JavaScript function that makes and changes and removes the controls.
READ :  Angular UI Grid Table Example Steps

Then conclusion is the scope is the Model.

The Scope Life Cycle

1. Creation phase or init
2. Watcher registration phase in angular
3. Model mutation phase in angular
4. Mutation observation phase
5. Scope destruction phase in angular

[php]

AngualrJS $scope object
http://infinityknow.com/libs/angular.min.js

StatusMessage:
{{statusmsg}}

var ngApp = angular.module(‘ngApp’, []);

ngApp.controller(‘firstCtrl’, function ($scope) {
$scope.statusmsg = “Hello World!”;
});

[/php]

Simple The AngularJS Life Cycle

  • In angularjs,The Bootstrap Phase.
  • In angularjs,The Compilation Phase.
  • In angularjs,The Runtime Data Binding Phase.

The Scope variable is a one special type of object or variable in AngularJS and it act’s like connects between controller side and view side. It can hold any type of valid javascript type including any object.

READ :  AngularJS Cookies Set Get and Remove Cookies

View Demo

Leave a Comment