I am trying to understand how to manage the scope in my Javascript code. Once I create a viewmodel, how do I access it from the rest of my javascript? (last line in this code generates a 'not defined' error
NOTE: I have found several posts on the differences between function/var for ko, but none have said there is a scoping advantage with using a var... so I have tried both methods.
//function AppViewModel() { // this.gridSize = ko.observable("30"); // this.canvasWidth = ko.observable("600"); // this.canvasHeight = ko.observable("600"); // this.displayCoords = "Axial"; // this.pixel="0"; // this.hex="0"; //} //ko.applyBindings(new AppViewModel()); var AppViewModel = { gridSize: ko.observable("30"), canvasWidth: ko.observable("600"), canvasHeight: ko.observable("600"), displayCoords: "Axial", pixel:"0", hex:"0" }; ko.applyBindings(AppViewModel ); var test = AppViewModel.gridSize;