-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(loaders): add jsonp support #547
feat(loaders): add jsonp support #547
Conversation
Adds support to make requests using jsonp method. Works on loader-url and loader-partial. ```javascript $translatePartialLoader({ key: 'en', urlTemplate: '/locales/{part}-{lang}.json?callback=JSON_CALLBACK', method: 'JSONP' }); ```
@juanpujol Yes, that's looking great! @PascalPrecht Should we not change the api to something like this? return function (options) {
if (!options || !options.url) {
throw new Error('Couldn\'t use urlLoader since no url is given!');
}
var deferred = $q.defer();
$http(angular.extend({
url: options.url,
params: { lang: options.key },
method: 'GET'
}, options.options || {})).success(function (data) {
deferred.resolve(data);
}).error(function (data) { |
@knalli yes! Do you wanna do it? |
Hello there! This pull request will be made? I was searching for a solution and this pull request will made it! Can you please merge this patch? Thanks a lot. |
Sorry, is not clear how to use that $http on the loader. I want to load my parts via jsonp. I tried this:
But I still get the No 'Access-Control-Allow-Origin', so is not working. Can somebody help me please? Thank you. |
Well, that's actually all you need. Do you use the latest 2.4? 'Access-Control-Allow-Origin' does mean nothing*, the question is only if the requested was made via JSONP.
|
Is not working. Before I had a forked version of the partial, forcing the |
Can you track this down on your own? It looks like I have accidentally swapped argument 2 and 3 here angular-translate/src/service/loader-partial.js Lines 49 to 52 in 6d35c6b
|
Yes, just swapped back the arguments and it worked like a charm =)
Thank You. |
I needed jsonp support so I did this small patch. Very easy to use. Just pass
method: 'JSONP'
as an option on$translateUrlLoader
.Works on loader-partial and loader-url.
Cheers.