0

I would like to ask if I am doing something wrong in my angularjs application. My HTML code is requested dynamically, but if I understand correctly single page apps should be loaded fully only once and each view should not be requested multiple times. For example every time I visit page /example with given templateUrl the following html template is loaded. It works fine, but I am scared that provided templates should load only fist time since it is a single page app.

.when('/example1', {
        templateUrl: 'example1.html',
        controller: 'example1Ctrl',
        controllerAs: 'vm'
    })
.when('/example2', {
            templateUrl: 'example2.html',
            controller: 'example2Ctrl',
            controllerAs: 'vm'
        })

example1.html is loaded when I am on /example1 and when I switch to /example2 example2.html is loaded etc.

1 Answer 1

0

You have nothing to worry about. Each html file requested in the routes is loaded on a per route basis and then discarded once you move to a new route. It honestly is nothing to worry about.

With that being said, if you still want your html files cached, you can use $templateCache to achieve that. Check out the Angular JS $templatecache docs for more info.

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

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.