-
Notifications
You must be signed in to change notification settings - Fork 3k
$templateFactory (0.3.1) is not using $templateRequest of AngularJS for templateUrl #3123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If you can get all the tests passing, Ill merge a PR. The code should be compatible with angular 1.2 and fall back to See this previous PR #1900 |
Hi Chris, I will take some on that and will post a pull request. But I am not sure that I will be able to make it compatible to Angular 1.2.x. One question though what do you mean by disabling $templateRequestProvider |
Wonderful news! ui-router supports ng 1.2. The code should be compatible with 1.2. It should fall back to
I meant to type |
I have spent some time on this. The only restriction I face that there is a requirement of sending the requests with header For the changes I have done in my local were simply replacing the Please suggest! |
I think that is OK. If we can't send a specific header in $templateRequest, then it's up to the user to set that header in the |
Thats a great news. I will do the required modifications and remove the test case validating that the header |
Hi @christopherthielen I have create a pull request and would like you to have a look at that. Here is the PR number #3155. |
Hi, interested bystander here :) this seems like a very positive change IMO, but keep in mind that $templateRequest will make template URLs go through the $sce.getTrustedResourceUrl code with it, while it doesn't right now. In the current state of things, ui-router bypasses the usual security checks Angular does on templates (for ng-include, for instance). These security policies might block some resources from loading: by default, it allows anything same-origin. You might have users breaking because of that (they'll get https://docs.angularjs.org/error/$sce/insecurl), and in these cases, the way to force template loading is to tell them to either adjust their whitelist or to use $sce.trustAsResourceUrl on the template url. So, going back to your PR, I'd strongly advise to test what happens with trusted objects as inputs, instead of just string-based URLs, as they have caused issues in similar refactoring I've worked with. If you provide externs for your library, they'll probably need to be updated too: the template URL sinks should also accept !Object. Finally, I'm glad to help if you need to :) |
Hi @rjamet, I kind of lost you there in 3rd para. Can you please explain it to me. |
It's totally achievable, but I meant that this is worth testing (at least informally). The security is there, and will throw if you try to do something that Angular considers dangerous, like loading a template from another domain. You can bypass that by wrapping URLs with $sce.trustAsResourceUrl, same as you'd do with trustAsHtml when binding HTML that shouldn't be sanitized, and that turns the string into an opaque Object. The last paragraph is just my experience doing these refactorings: there's very often small assumptions that the thing is a string somewhere in the flow, and that's the kind of stuff which is really easy to test but hard to review for. But yes, it doesn't sound like much work. |
I know it is much of a work to ask, but will that be possible for you to do the tests you are talking about. I am just a 3 months old personal on AngularJS. Also, |
I have a little work backlog right now, but I'll take a look and send your branch a PR by the end of the week. |
Thanks @rjamet |
Closed by #3182 |
With the use of $templateRequest it is possible to have additional configuration while making the requests for the template. But since the ui-router's $templateFactory is not using that, it is not possible to have additional configuration for the ui-view's templateUrl.
In my project (ASP.Net MVC), all the views are coming from acition views and we need to pass the headers to all the requests for view. But it seems it is not possible if I am using templateUrl for the ui-view.
I have overcome the issue by decorating the factory and overwriting the implementation.
The text was updated successfully, but these errors were encountered: