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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

how to start service of scan widget on programmatically

jry
4-Participant
4-Participant

how to start service of scan widget on programmatically

I'd like to invoke the start scan service automatically when my view is loaded. I try to use the code following :

 

$scope.init = function(){
$scope.app.fn.triggerWidgetService('scan-1','startscan');
};

angular.element(document).ready($scope.init);

 

but it's not working.

it's working when I use with show popup service or another service but only scan service is not working.

I'll be happy if someone can help me. Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

but I think your code should also work bacause the document ready is comming nearly / a little bit earlerer before '$ionicView.afterEnter' and  I think there all 2d should be  already loaded.

May be, there is only the service name the problem ->'startScan' instead of 'startscan'

View solution in original post

3 REPLIES 3

Hi @jry ,

I had in the past a project where the scan widget (widget id scan-1) was in a popup widget id = popup-1 

On start I did show the popup and start scan with the following code:

 

$scope.$on('$ionicView.afterEnter', function() {
$timeout($scope.$root.$broadcast('app.view["Home"].wdg["popup-1"].svc.showpopup'),100);
$timeout($scope.$root.$broadcast('app.view["Home"].wdg["scan-1"].svc.startScan'),500)
});

 

Important is to call the code when 2d is already initialized - this is guaranteed by the event  '$ionicView.afterEnter'

I think it should work also without popup- you can try

but I think your code should also work bacause the document ready is comming nearly / a little bit earlerer before '$ionicView.afterEnter' and  I think there all 2d should be  already loaded.

May be, there is only the service name the problem ->'startScan' instead of 'startscan'

jry
4-Participant
4-Participant
(To:RolandRaytchev)

Dear @RolandRaytchev ,

 

now the problem is fixed!!

it looks like a stupid problem so I just startscan instead of startScan.

 

Thank you so much!! 

Top Tags