简体   繁体   中英

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?

尝试这个

import {CustomDirective} from './Module';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM