Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
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.
Solved! Go to Solution.
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'
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'
Dear @RolandRaytchev ,
now the problem is fixed!!
it looks like a stupid problem so I just startscan instead of startScan.
Thank you so much!!