Angular 获取声明时出现预期错误

Angular 获取声明时出现预期错误,angular,Angular,我的部件代码 import { Component } from '@angular/core'; @Component{( selector: 'app-rooot', templateUrl: 'app.component2.html', styleUrls: ['app.component.css'] )} export class AppComponent2{ title='second app'; }; 我的模块代码 import { Browser

我的部件代码

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

@Component{(
    selector: 'app-rooot',
    templateUrl: 'app.component2.html',
    styleUrls: ['app.component.css']
)}
export class AppComponent2{
    title='second app';
};
我的模块代码

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { AppComponent2 } from './app.component2';

@NgModule({
  declarations: [
    AppComponent,
    AppComponent2
  ],
  imports: [
    BrowserModule
  ],
  providers: [],
  bootstrap: [AppComponent,AppComponent2]
})
export class AppModule { }

在组件decorator中,圆括号“{()}”的外侧有花括号,它需要在“({})”的另一侧。基本上,decorator是一个将对象作为参数的函数


(另一方面,我强烈建议使用angular cli创建组件,它将为您处理此类样板文件。)

在您的组件装饰器中,括号“{()}”的外侧有花括号,而“({})”则需要另一种方式。基本上,decorator是一个将对象作为参数的函数


(另一方面,我强烈建议使用angular cli创建组件,它将为您处理此类样板文件。)

错误是/第一个app/src/app/app.component2.ts(3,11):需要声明。检查文件路径app.component2是否正确/是文件路径正确…它位于app.component所在的同一目录中。获取app.component.com没有错误,错误为/第一个app/src/app/app.component2.ts(3,11):需要声明。检查文件路径app.component2是否正确/是文件路径正确…它位于app.component所在的同一目录中。app.component没有错误。哦…tq。但是它没有解决我的问题。错误仍然持续了这么多。现在没有错误。它对我起作用了。也许刷新问题让我觉得问题仍然存在。哦…这是tq。但它没有解决我的问题。错误仍然持续了这么多。现在没有错误。这对我来说很有效。也许刷新问题让我觉得问题仍然存在