Nikolay Pryahin
Nikolay Pryahin

Reputation: 397

Cannot import file in typescript

I wanted to use a typescrypt function from another file, but there is a problem:

I made a file Module.ts with an

export function CustomDirective(): ng.IDirective {
    var directive: ng.IDirective = <ng.IDirective>{//Filling directive here
    };
    return directive;
}

In app.ts (same folder) I tried to import this file and use in

angular.module(...).directive('name', CustomDirective())

I tried to use

import 'Module';
import Module = require('Module');//
import * as Module from 'Module'; // this two with Module.CustomFirective();

But if there is an import, there accures an error that Module cannot be found. And PublicController, BusyIndicator become also not found.

How do I insert file with a function properly?

Upvotes: 0

Views: 477

Answers (1)

Ravi Teja
Ravi Teja

Reputation: 1107

Try this

import {CustomDirective} from './Module';

Upvotes: 1

Related Questions