Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

docs(guide/Conceptual Overview): fix external api example #15336

Merged
merged 2 commits into from
Oct 31, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions docs/content/guide/concepts.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ different currencies and also pay the invoice.
<b>Total:</b>
<span ng-repeat="c in invoice.currencies">
{{invoice.total(c) | currency:c}}
</span>
</span><br>
<button class="btn" ng-click="invoice.pay()">Pay</button>
</div>
</div>
Expand Down Expand Up @@ -242,7 +242,7 @@ Let's refactor our example and move the currency conversion into a service in an
<b>Total:</b>
<span ng-repeat="c in invoice.currencies">
{{invoice.total(c) | currency:c}}
</span>
</span><br>
<button class="btn" ng-click="invoice.pay()">Pay</button>
</div>
</div>
Expand Down Expand Up @@ -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/**'
]);
}]);
</file>
<file name="finance3.js">
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 ' +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? This won't work if the plnkr is loaded ovr http: iirc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plnkrs are loaded over https. I had to add it, otherwise it didn't match.

'yahoo.finance.xchange where pair in ("PAIRS")&format=json&' +
'env=store://datatables.org/alltableswithkeys';
var currencies = ['USD', 'EUR', 'CNY'];
Expand Down Expand Up @@ -371,7 +379,7 @@ The following example shows how this is done with Angular:
<b>Total:</b>
<span ng-repeat="c in invoice.currencies">
{{invoice.total(c) | currency:c}}
</span>
</span><br>
<button class="btn" ng-click="invoice.pay()">Pay</button>
</div>
</div>
Expand Down