What is $scope in the client script of the service portal widget?

Rohit Reddy
Tera Contributor

What is $scope in the client script of the service portal widget?

1 ACCEPTED SOLUTION

Mahesh Baraska2
Kilo Expert

The $scope is the binding part between the HTML (view) and the JavaScript (controller).$scope is an object in Angular that holds all functions and properties.  This properties/method can be accessed in the html page. As we have done here for method hello () in html ng-click directive.

 

HTML will be as follows:

 

<div> <button ng-click="hello()"> Click </button> </div>

 

Client script will be as follows:

function($scope)

{

/* widget controller */

var c = this; //function

$scope.hello = function()

{

alert("Hello World");

}

}

 

As you can see above that the method hello () in html ng-click directive, this method is bound between client script and HTML due to $scope.

View solution in original post

2 REPLIES 2

Mahesh Baraska2
Kilo Expert

The $scope is the binding part between the HTML (view) and the JavaScript (controller).$scope is an object in Angular that holds all functions and properties.  This properties/method can be accessed in the html page. As we have done here for method hello () in html ng-click directive.

 

HTML will be as follows:

 

<div> <button ng-click="hello()"> Click </button> </div>

 

Client script will be as follows:

function($scope)

{

/* widget controller */

var c = this; //function

$scope.hello = function()

{

alert("Hello World");

}

}

 

As you can see above that the method hello () in html ng-click directive, this method is bound between client script and HTML due to $scope.

Mahesh23
Mega Sage