This question is locked. New answers and comments are not allowed.
Hi guys, I have one global object named App that gets instantiated right away. In my view I'm trying to use data-show="App.PrimaryController.OnViewShow" but I keep getting the following error:
Cannot read property 'PrimaryController' of undefined
If I take out the data-show attribute everything works fine. I've included code for all the involved parties. Any ideas on what could be going wrong? Btw, this is a typescript app, thanks!
===================================================
PRIMARY.HTML
------------------
<div data-role="view"
data-layout="app-layout"
data-show="App.PrimaryController.OnViewShow"
id="primaryview">
Hello from the primary view!!
</div>
===================================================
MAIN.TS //as in main() -- this file is what is used as the data-main attribute in my requirejs script tag
------------------
/// <reference path="../typings/require.d.ts" />
import MyApplication = require('../app/MyApplication');
var App: MyApplication = new MyApplication();
===================================================
MYAPPLICATION.TS
------------------
/// <reference path="../typings/require.d.ts" />
import PrimaryController = require("../app/controllers/PrimaryController");
class MyApplication
{
KendoApp: kendo.mobile.Application;
PrimaryController: PrimaryController;
constructor()
{
this.InitializeControllers();
this.InitializeKendoApp();
}
private InitializeControllers()
{
this.PrimaryController = new PrimaryController(this);
}
private InitializeKendoApp()
{
var appOptions: kendo.mobile.ApplicationOptions = {};
appOptions.initial = this.PrimaryController.View;
appOptions.layout = "app-layout";
appOptions.transition = "slide";
this.KendoApp = new kendo.mobile.Application($(document.body), appOptions);
}
}
export = MyApplication;
===================================================
PRIMARYCONTROLLER.TS
------------------
/// <reference path="../../typings/require.d.ts" />
import MyApplication = require('../../app/MyApplication');
import IController = require("../../app/controllers/IController");
class PrimaryController extends kendo.data.ObservableObject implements IController
{
UserItems: kendo.data.ObservableArray = new kendo.data.ObservableArray([]);
View: string;
constructor(public App: MyApplication)
{
super();
super.init(this);
this.View = "views/primary.html";
}
OnViewShow() : void
{
}
}
export = PrimaryController;
Cannot read property 'PrimaryController' of undefined
If I take out the data-show attribute everything works fine. I've included code for all the involved parties. Any ideas on what could be going wrong? Btw, this is a typescript app, thanks!
===================================================
PRIMARY.HTML
------------------
<div data-role="view"
data-layout="app-layout"
data-show="App.PrimaryController.OnViewShow"
id="primaryview">
Hello from the primary view!!
</div>
===================================================
MAIN.TS //as in main() -- this file is what is used as the data-main attribute in my requirejs script tag
------------------
/// <reference path="../typings/require.d.ts" />
import MyApplication = require('../app/MyApplication');
var App: MyApplication = new MyApplication();
===================================================
MYAPPLICATION.TS
------------------
/// <reference path="../typings/require.d.ts" />
import PrimaryController = require("../app/controllers/PrimaryController");
class MyApplication
{
KendoApp: kendo.mobile.Application;
PrimaryController: PrimaryController;
constructor()
{
this.InitializeControllers();
this.InitializeKendoApp();
}
private InitializeControllers()
{
this.PrimaryController = new PrimaryController(this);
}
private InitializeKendoApp()
{
var appOptions: kendo.mobile.ApplicationOptions = {};
appOptions.initial = this.PrimaryController.View;
appOptions.layout = "app-layout";
appOptions.transition = "slide";
this.KendoApp = new kendo.mobile.Application($(document.body), appOptions);
}
}
export = MyApplication;
===================================================
PRIMARYCONTROLLER.TS
------------------
/// <reference path="../../typings/require.d.ts" />
import MyApplication = require('../../app/MyApplication');
import IController = require("../../app/controllers/IController");
class PrimaryController extends kendo.data.ObservableObject implements IController
{
UserItems: kendo.data.ObservableArray = new kendo.data.ObservableArray([]);
View: string;
constructor(public App: MyApplication)
{
super();
super.init(this);
this.View = "views/primary.html";
}
OnViewShow() : void
{
}
}
export = PrimaryController;