0

Is there a way to refresh an ng-include asking it to refetch the template from server? i know i can remove the entry from the $templateCache via, $templateCache.remove('/templates/home'). but really ask the div to refresh the ng-include and thus repload it from the server.

usecase: apart from all other templates the home template is different whether you are logged in or not. it is so different that it is a separate template on the server. however it resides on the same route, the root of the app.

yet after a user refreshes the screen it loads the correct template, but when a user is logging in, the ng-include doesn't refresh. That is what i'm trying to fix.

but just emptying the templateCache does not fix this. as the view is not actually refreshed.

2 Answers 2

1

A rude way to force page refresh is to use $route.reload(). See http://docs.angularjs.org/api/ngRoute.$route

Sign up to request clarification or add additional context in comments.

1 Comment

somthing i couldn't do because i'm using a custom routing system, however I found a fix which just involves changing the url of the 2 templates, instead of having the server push 2 templates on 1 url, I let the client set the template on a scope variable. and when you include that path from the variable it will re-render when the variable changes. I will sum up the changes i made in an answer soon
0

technically not an answer to the question but we solved our situtation by not serving 2 templates on 1 url. so when you are logged in we fetch a template from a different url than when you are loggedin. this way you get the loggedin homepage versus the not loggedin homepage.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.