简体   繁体   English

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

[英]Angular2 with TypeScript: Declaration expected compiler error after @component

Im getting this kind of error despite of the fact i imported Component from angular2/core what should be its source is files are not downloaded through npm install or my node is needs to be upgrade 我得到这种错误,尽管我从angular2 / core导入的组件应该是它的来源是文件不是通过npm install下载的,或者我的节点需要升级

Here is my file 这是我的档案

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

@Component({

})

Define a class right after the component. 在组件后面定义一个类。

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

@Component({

})
class MyClass {

}

@Component is just a decorator that contains metadata for the class. @Component只是一个包含该类元数据的装饰器。 In other words it just defines stuff for your class in a more elegant way. 换句话说,它只是以更优雅的方式为您的课程定义内容。

The @Component function takes the configuration object and turns it into metadata that it attaches to the component class definition. @Component函数获取配置对象并将其转换为附加到组件类定义的元数据。 Angular discovers this metadata at runtime and thus knows how to do "the right thing". Angular在运行时发现这个元数据,因此知道如何做“正确的事情”。

Read more here 在这里阅读更多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM