Question

I have a small problem.

I have index.js

var loc = require('location');
function doClick (){
loc.doIt();
}

in location.js I have these

var dee  = 12;
exports.doIt = function() {
    alert(dee);
};

Which means that when I click on the button I can get the alert, however, I want to reach these information without a need of click - onLoad - besides I want to return two values not only one. How I can fix this maybe it has really an easy solution but because I have been working for a while my mind stopped working :)

regards

Was it helpful?

Solution

you should move your location.js to inside app/lib (as module). for example :

// app/lib/helper.js
exports.callAlert = function(text) {
   alert('hello'+ text);
}

and then call it in your controller like this :

var helper = require("helper"); // call helper without path and .js extension
helper.callAlert('Titanium');

and your problem should be solved :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top