Lets say I have a simple angular directive that looks like this:
app.directive('setFocus', ['$timeout', function($timeout) {
return {
restrict: 'AC',
link: function(_scope, _element) {
$timeout(function() {
_element[0].focus();
}, 0);
}
};
}]);
How can I write this using Typescript and get the $timeout accesible within the link function? My example would look something like this:
/// <reference path="../../reference.ts"/>
class SetFocus{
constructor() {
var directive: ng.IDirective = {};
directive.restrict = 'EA';
directive.scope = { };
directive.link= function ($scope, $element, $attrs) {
// How can I access $timeout here?
}
return directive;
}
}
directives.directive('setFocus', [SetFocus]);
This might be a silly example but it is the principle I would like to get working, which is using injected dependencies in the angular link function.