christopherthielen / ui-router-extras

THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
http://christopherthielen.github.io/ui-router-extras/
MIT License
917 stars 211 forks source link

Force reload causes push error on non-array variable #339

Closed RobbSadler closed 7 years ago

RobbSadler commented 7 years ago

In ct-ui-router-extras.js: The line below is used to force reload by adding a param to the watched params, however, this params variable is a javascript object, not an array and the push command causes an exception.

if (reloadStateTree) { ... params.push('$$uirouterextrasreload');

using ui-router 0.2.18

EDIT:(turns out I wasn't - double check you have the right ui-router!)

christopherthielen commented 7 years ago

This should be guarded by the version heuristics. Are you using latest ui-router-extras release?

                if (versionHeuristics.hasParamSet) {
                  var tempParam = new $urlMatcherFactoryProvider.Param('$$uirouterextrasreload');
                  params.$$uirouterextrasreload = ownParams.$$uirouterextrasreload = tempParam;
                  restore.restoreFunctions.push(function() {
                    delete params.$$uirouterextrasreload;
                    delete ownParams.$$uirouterextrasreload;
                  });
                } else {
                  params.push('$$uirouterextrasreload');
                  ownParams.push('$$uirouterextrasreload');
                  restore.restoreFunctions.push(function() {
                    params.length = params.length -1;
                    ownParams.length = ownParams.length -1;
                  });
                }
RobbSadler commented 7 years ago

using version 0.1.2 - it is coming into this block of code with params == { }

christopherthielen commented 7 years ago

it's OK that params == { }... In your case with 0.2.18 the versionHeuristics.hasParamSet should be true, so the top block should be invoked, not the bottom one.

RobbSadler commented 7 years ago

Thanks for the response.

OK, I double checked the ui-router version. Turns out that the bower_components version is not getting loaded, but instead one that was in the template we started with. I will update and re-check.

RobbSadler commented 7 years ago

OK, I rewired the ui-router to pull the latest (0.2.18, that I thought it was doing in the first place), and it now behaves.

Thanks for the input, Christopher!