Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (device)
Viewing all articles
Browse latest Browse all 250

Require global function in alloy.js, error at startup on device.

$
0
0

I want to use the same instance of "Data" from all my controllers and makes is global in alloy.js. It works fine in the simulator but on my device I get "Application Error: Couldn't find module: Data" at startup.

I'm using Titanium SDK 3.1.0.GA and Device iPhone 4S iOS 6.1.3.

Any suggestions?

alloy.js

var Data = require('Data');
Alloy.Globals.Data = new Data();

Data.js

var Data = function(){
    this.string = 'Hello';
}
 
Data.prototype.getString = function(){
    return this.string;
}
 
Data.prototype.setString = function(string){
    this.string = string;
}
 
module.exports = Data;

Viewing all articles
Browse latest Browse all 250

Latest Images

Trending Articles





Latest Images