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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

JS Expressions in the little boxes

Ike@ACE
15-Moonstone

JS Expressions in the little boxes

First, I was under the impression that the little JS boxes in Studio were able to hold expressions. Was I wrong?

 

Second, if I wasn't wrong, then I'm guessing that I'm not using the correct syntax for it. To clarify, I am creating a 3D HMD experience with voice commands, and I'm trying to fill in the JS box with the expression below:

 

if ($scope.app.params.ExperienceType != 'Child') { viewCtrl.Start(); }

 

Unfortunately, this isn't having the desired effect and is also causing the Start function to not fire at all. My question is, what syntax do I need to use for the ExperienceType variable? I feel like that is where the problem is, but I'm not sure how to fix it. If it's not that, then what else might it be?

ACCEPTED SOLUTION

Accepted Solutions

The best approach is to reference a function in the littel JS boxes for example

 

in your Home.jS create a function

 

$scope.doSomething () {

 

if ($scope.app.params.ExperienceType != 'Child') { viewCtrl.Start(); }

 

}

 

and in  the little box add

 

doSomething(); // without the $scope prefix. This approach  will call your function doSomething and will be able to reference $scope.app 

 

Also the JS boxes I believe do not  allow references to $scope that is the main reason I think your code is not working is not working -

 

 

 

 

View solution in original post

1 REPLY 1

The best approach is to reference a function in the littel JS boxes for example

 

in your Home.jS create a function

 

$scope.doSomething () {

 

if ($scope.app.params.ExperienceType != 'Child') { viewCtrl.Start(); }

 

}

 

and in  the little box add

 

doSomething(); // without the $scope prefix. This approach  will call your function doSomething and will be able to reference $scope.app 

 

Also the JS boxes I believe do not  allow references to $scope that is the main reason I think your code is not working is not working -

 

 

 

 

Announcements

Top Tags