Created
October 9, 2016 18:15
-
-
Save sebastianfrelle/25f03820b1a38fda927e92e953272b0b to your computer and use it in GitHub Desktop.
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
var MainModule = (function() { | |
var alertMsg = "Der er fejl izi game izi lyfe"; | |
function privateGetAlertMsg() { | |
return alertMsg; | |
} | |
function privateSetAlertMsg(newAlertMsg) { | |
alertMsg = newAlertMsg; | |
} | |
return { | |
getAlertMsg: privateGetAlertMsg, | |
setAlertMsg: privateSetAlertMsg | |
}; | |
}()); | |
// "Inject" det module, man vil bruge, som en parameter til en immediately-invoked functional expression. | |
// Fungerer lidt ligesom injection i Angular. | |
var PeopleModule = (function(superModule) { | |
// Her kan superModule (peger på MainModule) bruges | |
function privateDoSomething() { | |
alert(superModule.getAlertMsg()); | |
} | |
return { | |
publicDoSomething: privateDoSomething | |
}; | |
}(MainModule)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment