使用Angular的Plunkr:将https://run.plnkr.co/.../src/mycomponent.ts加载为" ./ mycomponent"时出错来自https://run.plnkr.co/.../src/app.ts

时间:2017-12-10 07:02:27

标签: angular plunker

我无法让Plunkr加载我的简单Angular 2应用程序

可在此处找到该项目:https://plnkr.co/edit/SDtOiIBkNsb36XM1zX79

当我运行它时,浏览器窗口卡在libGL error: unable to load driver: nouveau_dri.so libGL error: driver pointer missing libGL error: failed to load driver: nouveau libGL error: unable to load driver: swrast_dri.so libGL error: failed to load driver: swrast X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 155 (GLX) Minor opcode of failed request: 24 (X_GLXCreateNewContext) Value in failed request: 0x0 Serial number of failed request: 33 Current serial number in output stream: 34 上,在控制台中,我收到此错误:

Loading...

有一个similar question asked here,但问题是没有将Error: (SystemJS) SyntaxError: Invalid or unexpected token at eval (<anonymous>) at ZoneDelegate.invoke (https://unpkg.com/zone.js@0.8.18/dist/zone.js:392:26) at Zone.run (https://unpkg.com/zone.js@0.8.18/dist/zone.js:142:43) Evaluating https://run.plnkr.co/fjg2NzuQ2f38zFXu/src/mycomponent.ts Error loading https://run.plnkr.co/fjg2NzuQ2f38zFXu/src/mycomponent.ts as "./mycomponent" from https://run.plnkr.co/fjg2NzuQ2f38zFXu/src/app.ts 放在文件名之前。我确保我的路径都是正确的,我仍然得到错误。

2 个答案:

答案 0 :(得分:0)

您在选择器名称后缺少'

@Component({
  selector: 'my-component', // missing ' after selector here
  templateUrl: './mycomponent.html'
})

修正了plnkr:https://plnkr.co/edit/11WmtxKehLksFntitYGr?p=info

答案 1 :(得分:0)

可能的解决方案

错误状态: - / src / mycomponent.ts

@Component({
  selector: 'my-component',
  // templateUrl: './src/mycomponent.html'
  template: '<h3>The current user is {{currentUser}}</h3>'
})

并且在plunker中解决了路由错误

Plunker链接: -

https://plnkr.co/edit/WhIvfdXeI0isq8NdFGIz?p=preview