From d94e64b693ce5ba0e5b512340231ee3229d657dc Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Sat, 29 Oct 2016 18:50:33 +0200 Subject: [PATCH 1/2] docs(guide/Conceptual Overview): fix external api example --- docs/content/guide/concepts.ngdoc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/content/guide/concepts.ngdoc b/docs/content/guide/concepts.ngdoc index 73993d40f0ce..53947febc10f 100644 --- a/docs/content/guide/concepts.ngdoc +++ b/docs/content/guide/concepts.ngdoc @@ -141,7 +141,7 @@ different currencies and also pay the invoice. Total: {{invoice.total(c) | currency:c}} - +
@@ -242,7 +242,7 @@ Let's refactor our example and move the currency conversion into a service in an Total: {{invoice.total(c) | currency:c}} - +
@@ -318,13 +318,21 @@ The following example shows how this is done with Angular: this.pay = function pay() { window.alert('Thanks!'); }; + }]) + + .config(['$sceDelegateProvider', function($sceDelegateProvider) { + // Add the yahoo finance api to the list of trusted resource urls (required for JSONP) + $sceDelegateProvider.resourceUrlWhitelist([ + 'self', + 'https://query.yahooapis.com/v1/public/**' + ]); }]); angular.module('finance3', []) .factory('currencyConverter', ['$http', function($http) { var YAHOO_FINANCE_URL_PATTERN = - '//query.yahooapis.com/v1/public/yql?q=select * from ' + + 'https://query.yahooapis.com/v1/public/yql?q=select * from ' + 'yahoo.finance.xchange where pair in ("PAIRS")&format=json&' + 'env=store://datatables.org/alltableswithkeys'; var currencies = ['USD', 'EUR', 'CNY']; @@ -371,7 +379,7 @@ The following example shows how this is done with Angular: Total: {{invoice.total(c) | currency:c}} - +
From 85367ad3e644b3583c6a484ec31081624f2d2058 Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Sun, 30 Oct 2016 00:15:13 +0200 Subject: [PATCH 2/2] squash! yahoo api allows cross origin requests --- docs/content/guide/concepts.ngdoc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/docs/content/guide/concepts.ngdoc b/docs/content/guide/concepts.ngdoc index 53947febc10f..d3ef180047e0 100644 --- a/docs/content/guide/concepts.ngdoc +++ b/docs/content/guide/concepts.ngdoc @@ -318,21 +318,13 @@ The following example shows how this is done with Angular: this.pay = function pay() { window.alert('Thanks!'); }; - }]) - - .config(['$sceDelegateProvider', function($sceDelegateProvider) { - // Add the yahoo finance api to the list of trusted resource urls (required for JSONP) - $sceDelegateProvider.resourceUrlWhitelist([ - 'self', - 'https://query.yahooapis.com/v1/public/**' - ]); }]);
angular.module('finance3', []) .factory('currencyConverter', ['$http', function($http) { var YAHOO_FINANCE_URL_PATTERN = - 'https://query.yahooapis.com/v1/public/yql?q=select * from ' + + '//query.yahooapis.com/v1/public/yql?q=select * from ' + 'yahoo.finance.xchange where pair in ("PAIRS")&format=json&' + 'env=store://datatables.org/alltableswithkeys'; var currencies = ['USD', 'EUR', 'CNY']; @@ -345,7 +337,7 @@ The following example shows how this is done with Angular: var refresh = function() { var url = YAHOO_FINANCE_URL_PATTERN. replace('PAIRS', 'USD' + currencies.join('","USD')); - return $http.jsonp(url).then(function(response) { + return $http.get(url).then(function(response) { var newUsdToForeignRates = {}; angular.forEach(response.data.query.results.rate, function(rate) { var currency = rate.id.substring(3,6);