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

Here is my file

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

@Component({

})
share|improve this question
    
Decorators and classes are just function when translated to JavaScript (ES5). Decorator must have argument - a function - to be able to decorate it. In TypeScript this means that you must put something after a decorator. You can find more details in this article – Sasxa Jan 16 '16 at 8:30
up vote 7 down vote accepted

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. 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. Angular discovers this metadata at runtime and thus knows how to do "the right thing".

Read more here

share|improve this answer
    
why is it necessary to do that – blackHawk Jan 16 '16 at 8:06
    
I provided an update with a link to the documentation that you need. Try recreating the quickstart tutorial from the official angular 2 website so that it becomes more clear to you – Hristo Enev Jan 16 '16 at 8:09
    
also if i do that new error comes at class name that experimental support for decorator is featured that might change specify --experimentalDecorator to remove this warning, which is not warning whole red line under class name – blackHawk Jan 16 '16 at 8:12
    
Well you need to do some configuration in your .tsconfig file. You need to enable experimentalDecorators like this "experimentalDecorators": true. That's also in the quickstart. – Hristo Enev Jan 16 '16 at 8:17
    
If im including "experimentalDecorators": true im getting 99+ error saying duplicate identifier main, cache etc, i also tried other configuration like exclude : node module specified in tsconfig at quick start tutorial – blackHawk Jan 16 '16 at 8:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.