-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Configurable path in templateUrl in all directives #1051
Comments
@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. |
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. |
@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 |
@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. |
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.
The text was updated successfully, but these errors were encountered: