Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Declaration Expected

I am using typescript version 1.8 and getting this error. I am new to typescript please help.
npm version: 3.9

File: ponymain-app.component.ts

 import {Component} from '@angular/core';
    @Component({
        selector: 'ponyracer-app',
        template: `<h1>Hye bud!</h1>`
    })

File: Index.html

<body>
  <ponyracer-app>
    loading....
  </ponyracer-app>
</body>
like image 859
Bhawna Avatar asked Jul 09 '26 03:07

Bhawna


2 Answers

You need to attach the @Component decorator to a class directly and you will not get anything until you bootstrap your root component

I am assuming you main root component is PonyComponent

Here's a edited version of your code

import { bootstrap } from '@angular/platform-browser-dynamic';

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

@Component({ 
selector: 'ponyracer-app', 
template: `<h1>Hye bud!</h1>` 
}) 

class PonyComponent { }

bootstrap( PonyComponent );

Here's a good resource to start : https://angular.io/docs/js/latest/quickstart.html

like image 119
Priyesh Kumar Avatar answered Jul 11 '26 18:07

Priyesh Kumar


Sometimes stopping and starting ng serve also helps. It worked for me.

like image 21
Someone Avatar answered Jul 11 '26 18:07

Someone