Search code examples
titaniumtitanium-mobileappcelerator-titaniumtitanium-alloy

How to pass operator in label in titanium alloy


I have label

<Label id="textArea" text="0" />

I want to add numbers and operators in label, numbers are showing in label but operators are not showing in label. Same value I tried in console as

Ti.API.info('label = ' + $.textArea.text);

It is showing in console but not in label in app, why so?

Please help I am new in titanium.


Solution

  • The best way to achieve this, as I understand your question, is to create the text elsewhere.

    var text = 'The text is 8 + 5 = 13';
    $.textArea.setText(text);
    

    If you are having trouble with the operators showing, maybe you are executing the sum operation (as per my text example) in javascript and not adding it as a string?

    Failing example:

    $.textArea.setText('The text is ' + 8 + 5 + ' = 13');
    

    Hope this helps