Angular 2 Unhandled Promise rejection:模板解析错误

时间:2016-09-14 16:05:46

标签: javascript angularjs

您好我正在学习angular2,所以我想出了这个错误,不知道为什么。这很简单,请帮我解决。我有两个组件,尝试使用第一个组件模板中其他组件的选择器。组件已导入,因此我不知道为什么会出错。

Unhandled Promise rejection: Template parse errors:
'playlist' is not a known element:

第一个组件

import { Component } from '@angular/core';
import { ProductListComponent } from './product.component';
import { Video } from './video';
import { PlaylistComponent } from './playlist.component';
@Component({
  selector: 'my-app',
  templateUrl: 'app/app.component.html',
  directives: [PlaylistComponent]

})
export class AppComponent {

  head =ProductListComponent.MAIN
  videos = Array<Video>;

  constructor(){
    this.video = new Video(1,'youtube','axaEfeaS','Ovo je mnogo lepa deskripcija');
  }
}

第二部分

import { Component } from '@angular/core';

@Component({
  selector: 'playlist',
  templateUrl: 'app/playlist.component.html',

})
export class PlaylistComponent {

}

html app.component file
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<div><playlist></playlist></div>
</body>
</html>

需要帮助tnx

1 个答案:

答案 0 :(得分:0)

如果您使用的是2.0.0版,则@Component中的指令属性已过时。它可以通过大部分测试版获得,但最近在RC中删除了。

您需要查看最新的文档。您需要实现一个ngModule来传递该组件。