Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
AngularJS , Error going to Home
-
Jared, i have made a button bar that is supposed to send me back to home. When I hit the button, it takes me to home, but it goes into an endless loop. Attached are the errors I am getting and the app.js code and my page code.
I don't know how to fix this.0_1473664909729_to_home_errors.9.12.16 0_1473664925941_app.js 0_1473664946032_page1c.html
-
Hi Chris,
There is a bug in v3.2.0 which I have just fixed, v3.2.1 will fix the issue. To stop the redirect loop in the meantime make the following change to app.js
$rootScope.$on("$stateChangeError", function(event, toState, toParams, fromState, fromParams, error) { if (...) { ... } else { // remove $state.go and add the following instead console.log(error); } });
-
I changed it to look like this.
$rootScope.$on("$stateChangeError", function(event, toState, toParams, fromState, fromParams, error) { if (error && (error === 'No user' || error.status === 401 || error.status === 403)) { event.preventDefault(); $state.loginRedirectUrl = $state.href(toState, toParams); $state.go('login'); } else { // $state.go('dashboard.home'); console.log(error); } });
It still is showing the error. and not reloading the home page
-
I suspect you are having cache issues again, I suggest that when you are developing a dashboard you should
- Use Google Chrome
- Have the developer tools open
- Ensure the "disable cache" box is ticked on the network tab
- Inspect the loaded files to ensure your changes are being loaded
-
Hi Jared.
I have been doing all of that, and I still get the errors
From the Developer Tools in the Sources.. I looked at the app.js and here is what I have.
// redirect to login page if we can't retrieve the current user when changing state
$rootScope.$on("$stateChangeError", function(event, toState, toParams, fromState, fromParams, error) {
if (error && (error === 'No user' || error.status === 401 || error.status === 403)) {
event.preventDefault();
$state.loginRedirectUrl = $state.href(toState, toParams);
$state.go('login');
} else {
// $state.go('dashboard.home');
console.log(error);
}
});// change the bread-crumbs on the toolbar when we change state $rootScope.$on("$stateChangeSuccess", function(event, toState, toParams, fromState, fromParams) { var crumbs = []; var state = $state.$current; do { if (state.menuTr) { crumbs.unshift({stateName: state.name, maTr: state.menuTr}); } else if (state.menuText) { crumbs.unshift({stateName: state.name, text: state.menuText}); } } while (state = state.parent); $rootScope.crumbs = crumbs; });
-
OK great so we don't have a cache issue. Have you upgraded to 3.2.1?
Is it still going to the home page when an error occurs? I would be surprised if it is.