Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Configurable path in templateUrl in all directives #1051

Closed
tomaszkrym opened this issue Sep 20, 2013 · 4 comments
Closed

Configurable path in templateUrl in all directives #1051

tomaszkrym opened this issue Sep 20, 2013 · 4 comments

Comments

@tomaszkrym
Copy link

If the ui-bootstrap templates are served from server the templateUrl properties force to serve the templates from a particular location, that is not configurable and might be inconvenient in some setup.

IMHO there shoud be a service like uiBootstrapConfig, that would keep a property name templateUrlBasePath and the templateUrl in each directive should be like:
templateUrl: uiBootstrapConfig.templateUrlbasePath + '/module_subdir/directive_template.html'.

The uiBootstrapConfig shoud be returned from a provider, which default implementation could be replace by custom impl.

If this feature request and proposed solution is accepted, I can implement it.

@pkozlowski-opensource
Copy link
Member

@tomaszkrym I'm not sure what is your use case but you should never download templates for directives from HTTP server as it will make your application perform terribly. See #743 and #105 for more info. Feel free to re-open if you've got different use-case.

@tomaszkrym
Copy link
Author

In fact I have the templates (my application and ui-bootstrap, as I have customized some of them) put into <script /> tags in the main html document that is served from server. The templates are put there under the key, which is the url from where are served from the server and loaded into the template cache at the startup of the application. The problem is that the ui-bootstrap templateUrl depends on the path, the page is actually served.

@pkozlowski-opensource
Copy link
Member

@tomaszkrym I'm sorry, I'm probably tired but I'm not sure I understand what you mean... If you want to override just some of the templates from angular-ui/bootstrap just use <script> tags as described here: http://stackoverflow.com/a/17677437/1418796
Does it solve things for you? If not, why it is so?

@tomaszkrym
Copy link
Author

@pkozlowski-opensource I have a mechanism that crawls templates' directories (custom templates, customized ui-bootstrap templates, etc.) and creates the script elements in the .html document. The point is that in the script tag I need to provide the key, under which the template would be put into the templateCache. For the projects templates the real url is given (i.e. /myAppContext/ngTemplates/template/tooltip.html), so if for some reason the template is not there, it can be downloaded from the server. Also it is easier for new people in the project to find, where the actual template is in the project, repository, etc (and another thing is that I had problem with providing the relative templateUrl to the ui-router's state, but I haven't investigated the issue yet, so possibly the problem was on my side). As for now, it is not possible to configure the templateUrl in ui-bootstrap directives, so I had to change the mechanism to treat the templates for ui-bootstrap in the specific way.

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

No branches or pull requests

2 participants