Sorry, this may be a simple beginner question but I still get errors after following all instructions I could find.
I have a JS file (testjs.js), which I loaded in the resources as (testjs).
var hello = "Hello World!!!";
My component is as follow
<aura:component >
<ltng:require scripts="{!$Resource.testjs}" afterScriptsLoaded="{!c.doInit}" />
</aura:component>
My controller is as follow
({
doInit : function(component, event, helper) {
console.log('Start');
console.log(hello);
console.log('End');
}
})
When I run it, "Start" is displayed in the console. But it crashes at hello.
Action failed: c:Tryme$controller$doInit [hello is not defined]
Am I missing something? The console should display Hello World