You shouldn't usually assign to globals from a RequireJS module (i.e. set properties on window
).
/path/test.js
define(function() {
function test(val) {
alert(val);
}
return test;
}
/path/app.html
<!-- import requirejs ... -->
<script>
// Use the return value from the "test" module.
require(["test"], function(testFn) {
testFn("hello");
});
</script>