Created
December 12, 2014 00:49
-
-
Save devdays/6fe0f69be6adab917eb1 to your computer and use it in GitHub Desktop.
Object JavaScript - Define module has a dependency on another module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in project.js | |
define( | |
// an optional module ID | |
'product', | |
// this module needs the discount.js as a dependency | |
['discount'], | |
// the requireJS loader provides discount as a parameter. | |
// if you have more than one in the array above, then you get | |
// them in the same order for your function. | |
function (discount) { | |
// properties | |
var productName = ''; | |
var price = 1; | |
var discountedPrice = function (level) { | |
return price - (price * discount.calculatDiscount(level)); | |
}; | |
return { | |
productName: productName, | |
price: price, | |
discountedPrice: discountedPrice | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment