cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Call a function on changed value event

MaximeDid
8-Gravel

Call a function on changed value event

Hi everyone,

I would like to call a function on changed value event. How can I do this?

The value to be monitored is in a label, it is used to indicate the step of my animation. The property text of label is binded to CurrentStep of my 3D Model which contains animation sequences.

Thanks,

 

Maxime.

ACCEPTED SOLUTION

Accepted Solutions

Hello @MaximeDid ,

one possible option to define a change value event and to call an action when a widget property will chang   , is to use  the $watch angular construct / defintion in  javascript e.g. in the Home.js -> some code like this:

 

 $scope.$watch("view.wdg['label-1']['text']", 
         function (newValue, oldValue, scope) {
console.log("Old Value -befor it was changed =" + oldValue); 
//! it could be undefined first time called
console.log("new  Value -after it was changed =" + newValue); 
//prints the current $scope (copy) object passed to the $watch construct
// pay attention it has no $ !
console.warn(scope);// the scope variable passed to the function
// this is the same as $scope but has not the $-char
})

 

View solution in original post

2 REPLIES 2

Hello @MaximeDid ,

one possible option to define a change value event and to call an action when a widget property will chang   , is to use  the $watch angular construct / defintion in  javascript e.g. in the Home.js -> some code like this:

 

 $scope.$watch("view.wdg['label-1']['text']", 
         function (newValue, oldValue, scope) {
console.log("Old Value -befor it was changed =" + oldValue); 
//! it could be undefined first time called
console.log("new  Value -after it was changed =" + newValue); 
//prints the current $scope (copy) object passed to the $watch construct
// pay attention it has no $ !
console.warn(scope);// the scope variable passed to the function
// this is the same as $scope but has not the $-char
})

 

Hi @RolandRaytchev ,

 

It works very well, thank you!

Announcements

Top Tags