Service Portal: how to use $scope and "data" variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2022 04:16 PM
How is the $scope and "data" variables used in Service Portal Widgets and Angular Providers?
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2022 04:23 PM
Hello ,
You can use it for different purposes in client controller
Ex : $scope.myFirstFunction = function()
{ //execute your logic
}
The above script calls a function
In Service Portal a widget always has an isolated scope. This is something that has been set by the developers of Service Portal to ensure widgets play nicely together, and that you can have multiple instances of the same widget on a single page as they all have their own isolated space to play. The scope tree Not just is the DOM a tree, but scopes sit in a tree as well. You can think of the scope tree as a cut-down version of the DOM tree, with all the things that didn't create a new scope removed.
Please mark my answer correct if it helped you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 01:02 AM
$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.
Client Side:
$scope.carname = "Volvo";
HTML
<h1>{{carname}}</h1>
data:
data variable is used in the server side to store values and pass them to client-side/HTML.
Server Side:
data.msgClass='alert-success';
HTML:
<div class="{{data.msgClass}}"></div>