1

Looking for a suggestion of a good way to create an abstract directive in one module and load its template on different modules.

The scenario is the following: I have a web site split into two (web portal and backoffice) which are two different deploys. Both share a lot of modules and the layout but have different functionalities.

I would like for the menu directive and structure to be on a core/common module, but its template should be loaded by the modules, so that the core module doesn't need to know what specific deploy is being used!

I thought about using $templateCache on each module configuration process, but does anyone know a better option for this?

1 Answer 1

1

Yes, the only option to keep templates and the rest of the application in different JS bundles is $templateCache. Other options (directive inheritance or requireing and bundling template HTML files with Webpack) will likely result in monolithic bundles.

There's no separate template unit in AngularJS, so in order to be included in module, templates should be defined with $templateCache.put.

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

1 Comment

Many thanks for your reply. I have been testing it using $templateCache and it works fine, even though if it is not ideal, I can live with it! Will mark as solved since the alternatives don't seem that reliable then!

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.