The Angular gets some JSON from a service as part of the route resolve.
The JSON is injected into the controller as an Angular-ish deserialized object.
The properties of the object line up with the provided TypeScript class, so vm.foo.displayName
is successfully displayed on the html page for example.
But I think the methods defined in the TypeScript class are nowhere to be found, so when I try to call vm.foo.run()
, the console prints the error: TypeError: Object doesn't support property or method 'run'
module app.Samples {
export class Foo {
public typeName: string;
public displayName: string;
public run(): void {
alert("Running!");
}
}
}
module app.Samples {
interface IFoobarScope {
foo: Foo;
}
class FoobarController implements IFoobarScope {
foo: Foo;
static $inject = ['foo'];
constructor(foo: Foo) {
var vm = this;
vm.foo = foo;
vm.foo.run();
}
}
angular
.module('app.Samples')
.controller('app.Samples.FoobarController', FoobarController);
}