[英]Angular 4.1.0 in Plunker: adding component returns 404 XHR Error
I'm trying to use Angular 4 with Plunker and I can't manage to add a new component. 我正在尝试将Angular 4与Plunker一起使用,但无法添加新组件。 The URL is: https://plnkr.co/edit/1umcXTeug2o6eiZ89rLl?p=preview
网址为: https : //plnkr.co/edit/1umcXTeug2o6eiZ89rLl?p = preview
I've just created a new component - mycomponent.ts
- with the minimum of declarations. 我刚刚用最少的声明创建了一个新的组件
mycomponent.ts
。 Then, in app.ts
, I'm adding the importing declaration: 然后,在
app.ts
,我添加了导入声明:
import {MyComponent} from "./mycomponent";
and add the component in the declarations array within the @NgModule decorator: 并将组件添加到@NgModule装饰器内的声明数组中:
declarations: [ App, MyComponent ],
This last bit breaks it and returns a 404 XHR error. 最后一位将其破坏并返回404 XHR错误。 So far I just played with changing the import declaration ("./" or not), inline/URL template for the component template, chrome/firefox browsers but nothing works so far.
到目前为止,我只是在更改导入声明(是否为“ ./”),组件模板的内联/ URL模板,chrome / firefox浏览器,但到目前为止没有任何效果。 I'm inclined to think it's Plunker's fault :S
我倾向于认为这是Plunker的错:S
Change the name of mycomponent.ts
to src/mycomponent.ts
and it will work. 将
mycomponent.ts
的名称更改为src/mycomponent.ts
使用。
The error is because it can't include the component (bad pathing). 该错误是因为它不能包含组件(错误的路径)。
Don't forget to add <combo-compo></combo-compo>
to your app.ts
template. 不要忘记将
<combo-compo></combo-compo>
app.ts
<combo-compo></combo-compo>
到您的app.ts
模板中。
Check it out: 看看这个:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.