2016-07-13 51 views
24

我開始角度2計劃,我堅持了一個錯誤:ts1206裝飾這裏是無效的,角2

ts1206 decorators are not valid here

@Component({ // ts1206 decorators are not valid here 
    selector: 'my-app', 
    moduleId: module.id, 
    templateUrl: 'app.component.html', 
    styleUrls: ['app.component.css'] 
}) 

更新:

我tsconfig.json:

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true 
    } 
} 

我該怎麼處理它?

+1

了'@Component()'有直接在上課前要,做你在裝飾器下面有一個導出的類? –

+0

你的'tsconfig.json'中有什麼? –

+0

請參閱快速入門文章 - https://angular.io/docs/ts/latest/quickstart.html – Sanket

回答

50

的裝修必須直接上門例如導出的課前:

@Component({ 
    ... 
}) 
export class someComponent{} 

這正好同爲@Pipe@Directive@Injectable