-
Notifications
You must be signed in to change notification settings - Fork 27.4k
angular directive templateUrl should allow "text/html" Accept and content-type headers #6860
Comments
hmm... well it does make sense. Care to send a PR? |
I think the content-type for the templates should be "text/ng-template" so that it matches the mime type already defined for the script directive. https://docs.angularjs.org/api/ng/directive/script |
I'm actually running into a real use-case with this issue, where it would not only be more correct, but actually useful. The problem that we have is that our server can send back our login page HTML (as text/html) if a user stays on a page for too long before navigating and causing template(s) to be loaded. This results in the login page being injected where the template should be. The way we're going to work around it is with an http interceptor, setting the I think that for directives and routes it could be useful, as discussed, to allow the setting of HTTP headers, and probably at least setting a default value for @shawnbissell completely agree. Was just discussing this with a co-worker. It's definitely wrong to be serving templates as text/html, as they are just HTML fragments. @dmoscrop per http://tools.ietf.org/html/rfc6648 "X-" based headers are now deprecated. Basically, as long as you choose a sufficiently unique and meaningful mime type, you're free to invent your own. |
@jammnrose retracted! good to know |
👍 faced the same issue. |
Same Issue following the REST Convention. |
Set the `Accept` header on HTTP requests for templates to `text/html, text/ng-template`. Previously the default request headers sent by `$http` were used. Closes angular#6860
It is now possible to configure the Accept header for template requests. If a value is configured then this will override only the Accept property of the headers that are passed. If no value is configured then the request will use the default $http Accept header. Thanks to @luckycadow for help on this feature Closes angular#11868 Closes angular#6860
It is now possible to configure the Accept header for template requests. If a value is configured then this will override only the Accept property of the headers that are passed. If no value is configured then the request will use the default $http Accept header. Thanks to @luckycadow for help on this feature Closes angular#11868 Closes angular#6860
It is now possible to configure the options sent to $http for template requests. If no value is configured then the request will use the default $http options. Thanks to @luckycadow for help on this feature Closes angular#11868 Closes angular#6860
It is now possible to configure the options sent to $http for template requests. If no value is configured then the request will use the default $http options. Thanks to @luckycadow for help on this feature Closes angular#11868 Closes angular#6860
templateUrl is generally going to be expecting to receive HTML back from the server. To inform the server of that (according to RESTful best practices) it would be useful to be able to specify the headers for the $http request that fetches the actual template.
The default being used by angularJS is "application / json". It would be useful to be able to specify "text/html" instead for templateUrl. In addition I submit that should be the default for any request that expects HTML back from the server.
The text was updated successfully, but these errors were encountered: