0

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 { }
4
  • 1
    And the error is? ... Commented Dec 11, 2017 at 9:33
  • /first-app/src/app/app.component2.ts (3,11): Declaration expected. Commented Dec 11, 2017 at 9:34
  • check file path whether app.component2 is correct/ Commented Dec 11, 2017 at 9:35
  • yes the file path is correct ...it is in the same directory where app.component is present. Getting No error for app.component. Commented Dec 11, 2017 at 9:37

1 Answer 1

2

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.)

Sign up to request clarification or add additional context in comments.

2 Comments

Oh...tq for that .But it didn't fix my issue ..The error still persists
Tq so much. No error now . It worked for me .Maybe refresh issue that showed me like the issue is still there

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.