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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

How set image source from JS

jmikesell
15-Moonstone

How set image source from JS

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.
1 ACCEPTED SOLUTION

Accepted Solutions
ytella
17-Peridot
(To:jmikesell)

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!

View solution in original post

3 REPLIES 3

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

ytella
17-Peridot
(To:jmikesell)

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!

This is working perfectly fine! Thanks @ytella 

Top Tags