Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I have some issue with declaring a class. I have the following code:

module Directive.toast{
    import ToastService = Toaster.ToasterService;
    'use strict';

    interface IToastScope extends ng.IScope {
        message:string;
        display:boolean
    }

    class ToastDirective implements ng.IDirective {
        templateUrl= '/toast.html';
        restrict= 'AE';
        replace= true;
        scope = {
        };

        public message:any;
        public display:boolean;

        constructor(public Toast:ToastService, public $timeout:angular.ITimeoutService) {

        }

        link:ng.IDirectiveLinkFn = (scope:IToastScope, element:ng.IAugmentedJQuery, attributes:ng.IAttributes) => {
            scope.message = this.Toast.message.text;
            this.$timeout(function() {
                this.message.display= false;
                element.remove();
            }, 5000);
        };

        static factory():ng.IDirectiveFactory {
            return () => new ToastDirective();
        }
    }

    var app = AppModule.getModule();
    app.directive('toast', ToastDirective.factory());
}

Which gives me an error:

error TS2346: Supplied parameters do not match any signature of call target.

However, if I delete the injections from the constructor, it will pass through the compiler - but I do need to inject those dependencies, to use them in the linking functions to the directive. Any ideas?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.