- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2024 03:22 AM
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2024 06:01 AM
Hi @hemantnh,
Let's set the context and understanding here.
As @Upender Kumar very nicely and clearly explains in the below article, there is a difference between $scope and data. The simple high level difference between them is:
$scope is the binding part between HTML (view) and JavaScript (controller)
data is the variable used on the server side which can be leveraged to retrieve values which you can pass to client-side/HTML.
$scope:
The Scope in Angular JS is the binding part between HTML (view) and JavaScript (controller) and it is a built-in object. It contains application data and objects. It is available for both the view and the controller. It is an object with available properties and methods. There are two types of scopes in Angular JS.
Example usage:
Client Side:
$scope.carname = "Volvo";
HTML
<h1>{{carname}}</h1>
data:
is the variable used on the server side which can be leveraged to retrieve values which you can pass to client-side/HTML.
Example usage:
Server Side:
data.msgClass='alert-success';
HTML:
<div class="{{data.msgClass}}"></div>
What are you trying to achieve?
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
Article link: https://www.servicenow.com/community/developer-forum/service-portal-how-to-use-scope-and-quot-data-q...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2024 06:01 AM
Hi @hemantnh,
Let's set the context and understanding here.
As @Upender Kumar very nicely and clearly explains in the below article, there is a difference between $scope and data. The simple high level difference between them is:
$scope is the binding part between HTML (view) and JavaScript (controller)
data is the variable used on the server side which can be leveraged to retrieve values which you can pass to client-side/HTML.
$scope:
The Scope in Angular JS is the binding part between HTML (view) and JavaScript (controller) and it is a built-in object. It contains application data and objects. It is available for both the view and the controller. It is an object with available properties and methods. There are two types of scopes in Angular JS.
Example usage:
Client Side:
$scope.carname = "Volvo";
HTML
<h1>{{carname}}</h1>
data:
is the variable used on the server side which can be leveraged to retrieve values which you can pass to client-side/HTML.
Example usage:
Server Side:
data.msgClass='alert-success';
HTML:
<div class="{{data.msgClass}}"></div>
What are you trying to achieve?
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
Article link: https://www.servicenow.com/community/developer-forum/service-portal-how-to-use-scope-and-quot-data-q...