Listview Converter Application Resources error


Hi folks,

I’m trying to add a converter to a listview, and I’m following the documentation shown here:

But when I run the application (on Android), I get the following error:

TypeError: Cannot set property ‘dateFormat’ of undefined File: "file:///data/data/org.nativescript.[myapplicationname]/files/app/views/mylist/mylist.js’

The line in question that it points to is the last one in this block:

var application = require("application");
var moment = require("moment");

var dateFormat = function(value) {
     return moment(value).format();
application.resources["dateFormat"] = dateFormat;

What am I missing, here? Any ideas?


The application module changed.

Change this line:

application.resources["dateFormat"] = dateFormat;


var appResources = application.getResources();
appResources.dateFormat = dateFormat;


That did the trick, thanks!