I'm currently trying to create a simple TypeScript class, however I keep encountering an error stating this is undefined
in the constructor.
Class:
class MyNewClass {
items: string;
constructor(){
this.items = 'items';
}
}
app.config([MyNewClass]);
After compilation:
var MyNewClass = /** @class */ (function () {
function MyNewClass() {
this.items = 'items';
}
return MyNewClass;
}());
app_module_1.app.config([MyNewClass]);
Why is it not functioning correctly? Why is this
showing as undefined? The syntax used appears to be correct based on my previous experiences with code.
The rest of my working code:
export let app = angular.module('timeApp', [
uirouter
]);
class SecondaryController{
data: string;
constructor(){
this.data = "SUCCESS";
}
}
app.controller('secondaryController', SecondaryController);