Skip to content

reload() doesn't resolve templates #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ribizli opened this issue Jan 10, 2014 · 8 comments
Closed

reload() doesn't resolve templates #751

ribizli opened this issue Jan 10, 2014 · 8 comments
Labels
Milestone

Comments

@ribizli
Copy link

ribizli commented Jan 10, 2014

I've have a scenario to reload state if the user changes language. The language is changed on server side, so the templates are translated by the server (using a lang parameter or a session value for the language).

I've created a languageTemplateProvider function (used in state.templateProvider) like this:

function($http, $templateCache, languageService) {
    var langUrl = url + '?lang=' + languageService.selectedLanguage;
    return $http.get(langUrl, { cache: $templateCache })
        .then(function(response) { return response.data; });
}

On language change I clear the $templateCache so the template is re-downloaded from the server correctly.

But here comes the possible BUG: the state reloads/resolves before the $http finishes with the old template. Why?

On normal state change, the change happens only after the templates are correctly downloaded, so it seems correct (simulated with $timeout).

Sorry that I cannot provide a plunkr, but my app is already very complex to extract the needed components...

@timkindberg
Copy link
Contributor

I'm wondering... I don't think we reload templates for any states. Once its loaded its loaded and unexpected to change. So I don't think we'd reload templates for reload() either.

There is a bug where controllers don't get re-instantiated, and that is a problem we are fixing, but not sure about templates. Maybe this is more of a feature request.

@ribizli
Copy link
Author

ribizli commented Jan 13, 2014

I see, but anyhow the templates are still re-downloaded, as I can see in network tab. Can you please check/confirm this?

http://plnkr.co/edit/eHP5J8B97pxZBDWkZJuJ

Here the state a has language support, the template download is delayed with 2 seconds. State b is only a helper to load state a again when switching back to it. The language <li>s are clickable, I didn't bother with styling. State reload is called also on click. You can see in network tab the extra template load, which is unnecessary if template reloading not supported.

@timkindberg
Copy link
Contributor

Ok so the problem is that the first template loads fine (delay and all) but the second template (when clicking 'de') loads in the network tab but never replaces the 'en' template on the page. Correct?

@ribizli
Copy link
Author

ribizli commented Jan 14, 2014

Correct. Either no need to download, or the template should be replaced (but this might be a feature request as you mentioned).

@timkindberg
Copy link
Contributor

Actually I think this is a valid bug. The template should be replacing the previous one. Thank you for finding this.

@jglinsek
Copy link

@timkindberg,

There is a bug where controllers don't get re-instantiated, and that is a problem we are fixing

Is there an issue/commit for this? I just ran into this and don't know what the state of it is other than your comment.

@timkindberg
Copy link
Contributor

yep. #582.

@christopherthielen
Copy link
Contributor

Closing because this is really really old, the plunker link doesn't work, and I think this is fixed in 1.0 codebase. Please reopen if the issue is still valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants