phani kanna
phani kanna

Reputation: 27

Getting Declaration Expected error in angular

My Component Code

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

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

My Module Code

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 { }

Upvotes: 0

Views: 3155

Answers (1)

Brendan Whiting
Brendan Whiting

Reputation: 504

In your Component decorator, you have the curly braces on the outside of the parentheses "{()}", it needs to be the other way around "({})". Basically the decorator is a function that takes an object as an argument.

(P.S. I highly recommend creating components with the angular cli and it will take care of this kind of boilerplate for you.)

Upvotes: 2

Related Questions