Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I want to reset application parameters in Vuforia Studio after placing an order.The orderid is getting reused even after setting it to undefined ex: $scope.app.params['uid'] = undefined.Can you please help me with this.
Hi @SS_11298241 ,
when you set the parameter to an value you need to check what is the value there.
I believe that app parameter could not be set later to undefined but it is an empty string- there is some automatic parsing.
The quesiton how you did hanlde the setting a parmater value to undefined. Possibly you can use the string 'undefined' and check something like
if($scope.app.params['uid'].indexOf('undefined') !=-1) ... please see also https://stackoverflow.com/questions/2559318/how-to-check-for-an-undefined-or-null-variable-in-javascript
but possibly you can check an empty string https://stackoverflow.com/questions/5515310/is-there-a-standard-function-to-check-for-null-undefined-or-blank-variables-in
or not valid uid ... (so means the stinng does not match the uid requirments) I think you need to have define your function e.g. (check_valid_uid) what should be the best option.
It depends when you say reused - what that means. where you reuse .it ? e.g. $whatch construct or some service call.... you can even do you check if ui is valid or not.
Thanks
Hi Roland,
Thanks for responding to my previous post. Apologies if my earlier explanation was too vague. Here's a detailed description of the issue I'm facing with my cart application:
My cart application generates a unique ID (uid) whenever items are added to the cart. However, I've encountered an issue when users place multiple orders without refreshing the page.
First Order:
No Page Refresh:
Second Order:
The cart application reuses the uid for subsequent operations when the page is not refreshed, resulting in a merge of the previous order's items with the current one.
I would like the addToCart functionality to use a new uid for each order without requiring the user to refresh the page or triggering a location.reload().
How can I ensure that a new uid is generated and used for each order without requiring a page refresh?
I've attached my bindings for reference. Any suggestions or best practices to resolve this would be greatly appreciated.
Thanks in advance!
possibly we need to check more detailed the calling sequence to see why that happend
... but when you say - when the customer will not refresh the view. - so means that issue is chrome - is that also in view on device?
- and I will undertand your statement that it will work ok when user will referesh the view /browser after the order- therefore possibly via some a little stupid technques we can force the refresh. $sope.apply() - found follow internal info but never used it- so possibly you can try if that will referesh:
$scope.$apply() function takes a function as parameter which is executed, and after that $scope.$digest() is called
internally. That makes it easier for you to make sure that all watches are checked, and thus all data bindings refreshed.
Here is an $apply() example:
$scope.$apply(function() {
$scope.data.myVar = "Another value";
});
The function passed to the $apply() function as parameter will change the value of $scope.data.myVar. When the
function exits AngularJS will call the $scope.$digest() function so all watches are checked for changes in the watched
values.
one possible way to refersh I know is to call a second view widget
let say a dummy view widget what has e.g. a text saying something like " am processing your order" etc. let say you view is named order_process
so you can call
$scope.app.fn.navigate('order_process');
that will call the 2D view and there we can define in oder_process.js some think like :
$scope.$on("$ionicView.afterEnter", function (event,info) {
//======when the view is loaded
//then wait 1 second and navigate back to Home or what ever the name
$timeout( () =>{ //I will call with 2550 delay the srv
let navigateObject = {'viewname': 'Home'};
$scope.$emit('app-fn-navigate', navigateObject);}
},1000);
//-----------------------------
}) //######################## finish afterEnter view
So means you will navigate to the process_view and then after 1 second it will navigate back to the Home or what ever you name of the original view is. You can also use for that an app parameter e.g. $sope.app.params.CallingView e.g
$sope.app.params.CallingView ="MyStartView"
$scope.app.fn.navigate('order_process');
and then the defintion in order_process.js
$scope.$on("$ionicView.afterEnter", function (event,info) {
//======when the view is loaded
//then wait 1 second and navigate back to Home or what ever the name
$timeout( () =>{ //I will call with 2550 delay the srv
let navigateObject = {'viewname': $sope.app.params.CallingView };
$scope.$emit('app-fn-navigate', navigateObject);}
},1000);
//-----------------------------
}) //######################## finish afterEnter view
Could you check if that will work in your case? Thanks
Hello @SS_11298241,
It looks like you have some responses from some community members. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution.
Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.
Thanks,
Vivek N.
Community Moderation Team.