radioaktiv radioaktiv - 1 year ago 108
AngularJS Question

Module 'ng' has no exported member 'IDirective'

I am implemeting Angular 1 directive with TypeScript. Everything looks fine, it compiles, but I receive the following error in my Visual Studio Code editor:

Module 'ng' has no exported member 'IDirectiveFactory'.

Here is my code:

class MyDirective implements ng.IDirective {

constructor(a, b) {

static factory(): ng.IDirectiveFactory {
const directive = (a, b) => new MyDirective(a, b);
directive.$inject = ['a', 'b'];
return directive;

///more code

angular.module('module1').directive('mydirective', MyDirective.factory());

I tried to replace
, and that worked fine but the documentation says I should use the
module instead of the

Any ideas ?

Answer Source

I guess you're importing angular this way:

import * as angular from 'angular';

They probably import it in the documentation like this:

import * as ng from 'angular';

They do it because it's shorter :).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download