I cannot seem to get a component to load even a basic static resource script when Locker Service is active in a Winter preview sandbox. It works fine if Locker Service is deactivated. Otherwise, I get the following error. What am I doing wrong?
Something has gone wrong. Action failed: c$LockerTestComp$controller$doInit [lockerTest is not defined] Failing descriptor: {c$LockerTestComp$controller$doInit}. Please try again.
LockerTest.vfp
<apex:page >
<apex:includeLightning />
<div id="lightning"></div>
<script type="text/javascript">
$Lightning.use("c:LockerTestApp", function() {
$Lightning.createComponent('c:LockerTestComp', {}, "lightning", function(cmp) { });
});
</script>
</apex:page>
LockerTestApp.app
<aura:application extends="ltng:outApp" >
</aura:application>
LockerTestComp.cmp
<aura:component >
<ltng:require scripts="{!$Resource.LockerTest}" afterScriptsLoaded="{!c.doInit}" />
Hello World
</aura:component>
LockerTestCompController.js
({
doInit : function(component, event, helper) {
lockerTest();
}
})
LockerTest.js (static resource)
var lockerTest = function() {
alert('it worked');
}