简体   繁体   English

无法导入打字稿中的文件

[英]Cannot import file in typescript

I wanted to use a typescrypt function from another file, but there is a problem: 我想使用另一个文件中的typescrypt函数,但是有一个问题:

I made a file Module.ts with an 我制作了一个文件Module.ts

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 在app.ts(相同的文件夹)中,我尝试导入此文件并在

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. 而且PublicController和BusyIndi​​cator也都找不到。

How do I insert file with a function properly? 如何正确插入具有功能的文件?

尝试这个

import {CustomDirective} from './Module';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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