AngularJS directives specify a controller using:
{
controller: function ($scope){}
}
As of yet, I have not found a way where I can create a TypeScript class and assign it to a directive's controller property.
What I would like to do is something like
interface IDirectiveController{
myProperty:string;
}
class DirectiveController implements IDirectiveController{
static $injector = [$scope];
constructor ($scope:ng.IScope){
this.myProperty = 'default';
}
public myProperty:string;
}
var directive:ng.IDirective =
{
controller:DirectiveController;
}
return directive;
Better yet, it would be nice if a factory function could be used that would let me create and return a new instance of the controller, similar to how the directive itself is instantiated.
In my directive template I would also like to bind directly to the controller rather than having to assign the properties of the class to $scope.
Another way of stating this might be to say, I would like to be able to assign controllers to directives in a manner similar to assigning a controller using the myController as ContollerType syntax that is available in a template.