문제

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

도움이 되었습니까?

해결책

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 :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top