angular - Angular 2 中的导入是如何工作的?

标签 angular

我遵循了 Angular2 的 QuickStart。与教程相比,我制作了不同的文件夹结构。我遇到了找不到模块...的错误。

我知道错误的原因是导入问题。

我的文件夹结构: enter image description here

我已经在 hero.ts 文件中导出了 hero 接口(interface)。我想在 hero-detail.component.ts 文件中导入这个接口(interface)。

我试过:

import {Hero} from '../app/hero';
import {Hero} from './hero';
import {Hero} from './app/hero';

这些都不起作用。

index.html中的系统配置

enter image description here

我的问题是:

导入在 Angular 2 中是如何工作的?

最佳答案

那么你可能需要类似的东西

import {Hero} from '../hero';

关于angular - Angular 2 中的导入是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34816470/

相关文章:

angular - 使用 Angular 2中的viewchild更新元素的innerhtml

Angular 5 Material Update mat-select when list of mat-options Change

angular - 如何设置 Angular 2 组件属性的默认值?

Angular2 react 形式根据验证失败条件显示错误消息

angular - 从 ngrx/store 中提取特定数据

angular - {{myArray}} 现在在 beta.16 的 View 中更新

node.js - rxjs 订阅返回重复项

javascript - 将表单验证绑定(bind)到当前组件之外的组件

Angular2 ng-bootstrap 模态组件

javascript - 跟踪组件内数组变化的最佳方法是什么?