dotJEM / angular-routing

Enhanced state based routing for Angular applications!
https://dotjem.github.io/angular-routing/
MIT License
75 stars 9 forks source link

child view or a sticky view not-rendered #52

Closed soundstep closed 11 years ago

soundstep commented 11 years ago

When you destroy the scope here: https://github.com/dotJEM/angular-routing/blob/master/src/directives/jemView.ts#L87

function destroyScope() {
    if(viewScope) {
        viewScope.$destroy();
        viewScope = null;
    }
}

You also need to reset the version number:

The best place I found for that is in the update function:

function update(doAnimate) {
....
if(view && view.template) {
    ....
} else {
    version = -1;
    clearContent(doAnimate);
}

Here is my setup:

/vis/123 sticky = true, name = main, view = "main" /vis/123/subpage no sticky, name = main.sub, view = "mainsub"

Browsing there urls in that order work as intended: /vis/123/subpage /vis/124/subpage /vis/125/subpage

But these: /vis/123/subpage /vis/123 /vis/123/subpage /vis/123

The version of the child view (main.sub) is always 0 and is not getting re-created. That's why I reset the view version on destroy.

I'll do a plunkr when I'll be able to get some time :(

Does that make sense?

jeme commented 11 years ago

The best place I found for that is in the update function

Considering how the code looks right now, it also seems like the right place as the other branch of the if is the one updating the version as well.

And this should be added in the latest commit.

soundstep commented 11 years ago

Got it, thanks!