Skip to main content
1-Visitor
May 29, 2018
Solved

How set image source from JS

  • May 29, 2018
  • 2 replies
  • 3055 views

I would like to set the image source in JS but i can't seem to get it to work. I have tried all of these but non seem to work. But they also do not produce an error in the console.

 

 
$scope.view.wdg['image-1']['source'] = 'tech1en.png';
$scope.view.wdg['image-1']['source'] = 'resources/Uploaded/tech1en.png';
$scope.view.wdg['image-1']['source'] = 'app/resources/Uploaded/tech1en.png';
If i use an application parameter to store the image source value (and then change that parameter with JS) and link that to the image source in Studio it works but this is an extra step i would like to avoid.
Best answer by ytella

Hi @jmikesell,

 

Please use the below line to set the image source using JS for a mobile AR experience :


       $scope.view.wdg['image-1']['imgsrc'] = 'app/resources/Uploaded/download.jpg';

 

Let me know if this helps!

2 replies

16-Pearl
May 30, 2018

I've used this code successfully for setting the source for 3D images in experiences on the HoloLens:

 

$scope.setWidgetProp("instruction_image", "src", "app/resources/Uploaded/finished.png");

 

Hope this helps.

 

Allan

ytella17-PeridotAnswer
17-Peridot
May 30, 2018

Hi @jmikesell,

 

Please use the below line to set the image source using JS for a mobile AR experience :


       $scope.view.wdg['image-1']['imgsrc'] = 'app/resources/Uploaded/download.jpg';

 

Let me know if this helps!

16-Pearl
September 19, 2023

This is working perfectly fine! Thanks @ytella