NativeScript / sample-Groceries

:green_apple: :pineapple: :strawberry: A NativeScript-built iOS and Android app for managing grocery lists
Apache License 2.0
485 stars 345 forks source link

get textview not working #326

Open Gurucharan opened 5 years ago

Gurucharan commented 5 years ago

Hello, I was trying to get the user input from the text view. but it shows exception. please help me on this issue.

const editState = vm.get("editState");
console.log(editState);

Full Code is here.

main-page.js

// >> list-view-create-code const fromObject = require("tns-core-modules/data/observable").fromObject;

var view = require("tns-core-modules/ui/core/view");

var dialogs = require("tns-core-modules/ui/dialogs"); var new_note_title;

function onNavigatingTo(args) { const page = args.object; const vm = fromObject({ // Setting the listview binding source myTitles: [ { title: "going to gym" }, { title: "electricity bill due date" }, { title: "need to buy one book" }, { title: "tank fill petrol" }, { title: "insurance premium bill" }, { title: "lunch bag" } ] }); page.bindingContext = vm; } exports.onNavigatingTo = onNavigatingTo;

function onListViewLoaded(args) { const listView = args.object; } exports.onListViewLoaded = onListViewLoaded;

function onItemTap(args) { const index = args.index; console.log(Second ListView item tap ${index}); } exports.onItemTap = onItemTap; // << list-view-create-code

function onTap(args) {

const page = args.object.page;
const vm = page.bindingContext;
// >> list-view-refresh
const listView = page.getViewById("listView");
page.bindingContext.myTitles.push({ title: new_note_title });
// Manually trigger the update so that the new color is shown.
listView.refresh();
// << list-view-refresh

} exports.onTap = onTap;

function newNote(args){

const button = args.object;
const page = button.page;
page.frame.navigate("add-item");

} exports.newNote = newNote;

add-item.js

const fromObject = require("tns-core-modules/data/observable").fromObject;

exports.onPageLoaded = function(args) { }

function onCreateTap(args) { const button = args.object; const page = button.page; const vm = page.bindingContext; const editState = vm.get("editState"); console.log(editState); page.frame.navigate("main-page");
} exports.onCreateTap = onCreateTap;

add-item.xml