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

removing confusing use of hoisting #6207

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
25 changes: 15 additions & 10 deletions docs/content/guide/concepts.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,23 @@ Let's refactor our example and move the currency conversion into a service in an
<file name="finance2.js">
angular.module('finance2', [])
.factory('currencyConverter', function() {

var currencies = ['USD', 'EUR', 'CNY'],
usdToForeignRates = {
USD: 1,
EUR: 0.74,
CNY: 6.09
};

function convert(amount, inCurr, outCurr) {
return amount * usdToForeignRates[outCurr] * 1 / usdToForeignRates[inCurr];
}

return {
currencies: currencies,
convert: convert
};

function convert(amount, inCurr, outCurr) {
return amount * usdToForeignRates[outCurr] * 1 / usdToForeignRates[inCurr];
}

});
</file>
<file name="invoice2.js">
Expand Down Expand Up @@ -329,12 +332,7 @@ The following example shows how this is done with Angular:
currencies = ['USD', 'EUR', 'CNY'],
usdToForeignRates = {};
refresh();
return {
currencies: currencies,
convert: convert,
refresh: refresh
};


function convert(amount, inCurr, outCurr) {
return amount * usdToForeignRates[outCurr] * 1 / usdToForeignRates[inCurr];
}
Expand All @@ -351,6 +349,13 @@ The following example shows how this is done with Angular:
usdToForeignRates = newUsdToForeignRates;
});
}

return {
currencies: currencies,
convert: convert,
refresh: refresh
};

}]);
</file>
<file name="index.html">
Expand Down