node.js – 带有TypeScript的Angular2:在@component之后声明预期的编译器错误

我得到这种错误,尽管我从angular2 / core导入的组件应该是它的来源是文件不是通过npm install下载的,或者我的节点需要升级

这是我的档案

import {bootstrap} from 'angular2/platform/browser';
import {Component,View} from 'angular2/core';

@Component({

})

解决方法

在组件后面定义一个类.
import {bootstrap} from 'angular2/platform/browser';
import {Component,View} from 'angular2/core';

@Component({

})
class MyClass {

}

@Component只是一个包含该类元数据的装饰器.换句话说,它只是以更优雅的方式为您的课程定义内容.

The @Component function takes the configuration object and turns it into Metadata that it attaches to the component class deFinition. Angular discovers this Metadata at runtime and thus kNows how to do “the right thing”.

Read more here

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...