javascript - Plunker : adding component returns 404 XHR Error 中的 Angular 4.1.0

标签 javascript angular components plunker

我正在尝试将 Angular 4 与 Plunker 一起使用,但我无法添加新组件。网址是: https://plnkr.co/edit/1umcXTeug2o6eiZ89rLl?p=preview

我刚刚用最少的声明创建了一个新组件 - mycomponent.ts。 然后,在 app.ts 中,我添加了导入声明:

import {MyComponent} from "./mycomponent";

并在@NgModule 装饰器中的声明数组中添加组件:

 declarations: [ App, MyComponent ],

最后一位会破坏它并返回 404 XHR 错误。到目前为止,我只是尝试更改导入声明(或不更改“./”)、组件模板的内联/URL 模板、chrome/firefox 浏览器,但到目前为止没有任何效果。我倾向于认为这是 Plunker 的错 :S

最佳答案

更改 mycomponent.ts 的名称至 src/mycomponent.ts它会起作用的。

错误是因为它不能包含组件(路径错误)。

不要忘记添加 <combo-compo></combo-compo>给你的app.ts模板。

检查一下:

enter image description here

关于javascript - Plunker : adding component returns 404 XHR Error 中的 Angular 4.1.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43678614/

相关文章:

javascript - 到达页面底部时发出警报 当我在顶部时发出警报

javascript - Ionic v2 中的布局页面

Angular 2 RC6 - 在 URL 中设置默认参数并重定向到带有参数的路由

events - Angular Dart 组件事件

javascript - 样式 z-index 不起作用

javascript - 使用正则表达式获取单词后的名称

javascript - 验证表单 : Return false not possible/Always starts the action of the form

Angular 4 : Store pipe output variable for use outside of template

file - 在 Ember.js 中输入类型 ="file"

angular - 使用 REST API 时 mat-table 数据源不起作用