JS Expressions in the little boxes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
Solved! Go to Solution.
- Labels:
-
Coding
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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 -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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 -
