0

I am developing angular directives that used html template.

angular.module("app")
       .directive("ticket", [function(){
            return {
                restrict: "E",
                templateUrl: "app/ticket/ticket.html"
             }
        }])

This directive is working and I can change ticket.html content and run application to see changes.

But I read about $templateCache method to increase performance of big projects. And I can use grunt-angular-template to create all of template cache.

But I need to change my directive.

angular.module("app")
       .directive("ticket", ["$templateCache",function($templateCache){
            return {
                restrict: "E",
                template: $templateCache.get("app/ticket/ticket.html")
             }
        }])

Can I separate the build and deployment usage of template.

  • templateUrl: "app/ticket/ticket.html"
  • template: $templateCache.get("app/ticket/ticket.html")

I will select one of that ways. What is the professional approach for this?

1 Answer 1

1

You do not need to update this, you will automatically get it from the cache if you leave your code as it is, here you are just passing a template path to angular and angular gets it for you from the cache. $templateCache.get("app/ticket/ticket.html") is only needed if you want to load a template via js.

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.